Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature 3 #15

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
module.exports = {
env: {
browser: true,
commonjs: true,
es2021: true
},
extends: 'standard',
overrides: [
{
env: {
node: true
},
files: [
'.eslintrc.{js,cjs}'
],
parserOptions: {
sourceType: 'script'
}
}
],
parserOptions: {
ecmaVersion: 'latest'
},
rules: {
}
}
12 changes: 12 additions & 0 deletions .github/workflows/api-testing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: API Testing

on: [push]

jobs:
api-tests:
name: API Tests
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v3
- run: echo "API TESTING HERE....."
15 changes: 15 additions & 0 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Lint checking

on: [push]

jobs:
lint-check:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: Install dependencies
run: npm install
- name: Run eslint check
run: npm run lint

3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ node_modules
.vscode
npm-debug.log
.serverless
variables.env
variables.env
.env
16 changes: 0 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,5 @@
# nodejs-restful-api
![RESTful API design with Node.js](https://cdn-images-1.medium.com/max/2000/1*jjYC9tuf4C3HkHCP5PcKTA.jpeg "RESTful API design with Node.js")

How to create a RESTful CRUD API using Nodejs?

This tutorial will demo how to set up a bare bones
API using mongodb as the database.

It consist of a User model and controller. The model
defines the data, and the controller will contain all
the business logic needed to interact with the database.

It has a db file which will be used to
connect the app to the database, and an app file used
for bootstrapping the application itself.

The server file is used to spin up the server and tells the
app to listen on a specific port.

Full tutorial can be found at:
https://hackernoon.com/restful-api-design-with-node-js-26ccf66eab09#.s5l66zyeu
12 changes: 6 additions & 6 deletions app.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
var express = require('express');
var app = express();
var db = require('./db');
const express = require('express')
const app = express()
// const db = require('./db')

var UserController = require('./user/UserController');
app.use('/users', UserController);
const UserController = require('./user/UserController')
app.use('/users', UserController)

module.exports = app;
module.exports = app
4 changes: 2 additions & 2 deletions db.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
var mongoose = require('mongoose');
mongoose.connect('mongodb://yourMongoDBURIGoesHere');
const mongoose = require('mongoose')
mongoose.connect('mongodb://dangnguyen92:[email protected]:27017,ac-tbxgfag-shard-00-01.hhdv7oq.mongodb.net:27017,ac-tbxgfag-shard-00-02.hhdv7oq.mongodb.net:27017/boho?ssl=true&replicaSet=atlas-m1ipys-shard-0&authSource=admin&retryWrites=true&w=majority')
1 change: 1 addition & 0 deletions dummy.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dummy
Loading