- User service API for web & mobile apps
-
Install Node.js v8.6.0
-
Install npm v5.3.0
-
Install project dependencies:
-
Install all dependencies defined in package.json:
npm install
-
-
Setup environment variables
This project uses dotenv, please configure the proper environment variables before running this application.
- Copy the
.sample-env
file and rename it to.env
- Edit all sample fields with the correct environment variables for the application server
- Copy the
-
Database migration (using Sequelize):
- create model (and migration):
node node_modules/.bin/sequelize model:create --name <model_name> --attributes <attributes>
- create migration:
node node_modules/.bin/sequelize migration:create
- run:
node node_modules/.bin/sequelize db:migrate
- undo:
node node_modules/.bin/sequelize db:migrate:undo
- help:
node node_modules/.bin/sequelize help
- create model (and migration):
-
How to run tests:
npm test
-
Deployment instructions
npm start
ornode index.js
-
Writing tests:
This project use Mocha as the testing environment, and Chai as the assertion library. This project also provide code coverage using Istanbul. Code coverage report can be viewed in
coverage/lcov-report/index.html
after running test. All test files should be located under thetests
directory. -
Writing code:
Please fork this repository first for starting a contribution. This project use ESLint as Javascript lint library.
- To run ESlint, type
node node_modules/.bin/eslint .
- Fixing code errors, just type
node node_modules/.bin/eslint . --fix
- To run ESlint, type
*endpoint
Method : GET
Desc : get all user
http://localhost:8000/user
Method : GET
DESC : get user by id
http://localhost:8000/user/:id
Method : POST
DESC : create new user
http://localhost:8000/user
Content-type : application/json
body :
`{
"email" : "someemail@email.com",
"username" : "someUsername",
"password" : "somePassword"
}`
Method : PUT
DESC : update user
http://localhost:8000/user/:id
Content-type : application/json
body :
`{
"email" : "someemaieditedl@email.com",
"username" : "someUsernameEdited",
"password" : "somePasswordEdited"
}`
Method : DELETE
DESC : delete user by id
http://localhost:8000/user/:id
Method : GET
DESC : get all data
http://localhost:8000/todo?username=someUsernamef&password=somePassword&priority=(DESC || ASC)
Method : GET
DESC : get one data
http://localhost:8000/todo/:id?username=someUsernamef&password=somePassword
Method : POST
DESC : add data
Content-type : application/json
http://localhost:8000/todo?username=someUsernamef&password=somePassword
body :
`{
"name" : "string",
"priority" : "number",
"location" : "string",
"time_start" : "datetime"
}`
Method : PUT
DESC : update data
Content-type : application/json
http://localhost:8000/todo/:id?username=someUsernamef&password=somePassword
body :
`{
"name" : "string",
"priority" : "number",
"location" : "string",
"time_start" : "datetime"
}`
Method : DELETE
DESC : update data
Content-type : application/json
http://localhost:8000/todo/:id?username=someUsernamef&password=somePassword