CRUD api using aws lambda serverless framwork, node, express and MongoDB.
- Register User with name, phone no and password.
- User login and returns jwt token to access protected routes.
- User update(jwt protected) : A user can update its details.
- Get User Details(jwt protected) : User details can be retrieve using phone no.
- View all Users (jwt protected) : Get all users details excluding password.
( prerequisites : Nodejs
and serverless
installed in your system. )
- Clone this project
- Install all dependencies by
npm install
- Config MongoDB by adding your db connect url in
src/config/mongoose.js
- Add your ACCESS_TOKEN_SECERT in
.env
(it can be any String used for Encryption and Decryption of JWT token) serverless offline
orsls offline
- setup
serverless
with your aws credentials. - Change region according to your preference in
serverless.yml
severless deploy
orsls deploy
-
/user/create
(POST): Register User with name, phone and password.
Example input:
Example output:
-
/user/login
(POST): login User with your phone no and password.
Example input:
Example output:(Recieve jwt token in response)
All further requests will include JWT token in Authorization header.
-
/user/update
(POST): Update User details with name, phone and password.
Example input:
Example output:
-
/user/get/:phone
(GET): Get a Particular user details. Example output:
-
/user/get/:phone
(GET): Get all user details. Example output:
src
Contains all source code.
src/config
Contains config files for js libries used in project.
src/middleware
Contains middleware files used in server.
src/controllers
Contains functions for controlling the api endpoints.
src/models
Contains database models.
src/routes
Contains all routes.