This is an api which allows users to create an account, login and create an order for a parcel.
- Node.js
- Express --server handling
- JSON Web Token --Authentication
- Bcrypt -- Password hashing
- mongoose --Database Management
- nodemon --automatic refreshing of the server
|--index.js
|--server
|--routes
|--parcels.js
|--parcelsuser.js
|--register.js
|--login.js
|--helpers
|--validation.js
|--models
|--Parcels.js
|--User.js
- PORT --
server port number 3003
- DB_CONNECT --
database URL
- SECRET_KEY --
Secret key for verifying the token
- NODE_ENV --
Specifies the Server environment (development, local, production)
clone
this repository.cd
into project root directory.- run
npm install
to install all dependencies.(you must have pre-requisites) - Run
npm start
to start the server. - Open up
Postman
and then test out the Endpoints.
Signs in a user into the Application.
Endpoint | Method | Params | Data-type |
---|---|---|---|
/api/v1/auth/signup | POST | None | None |
Request Body
{
"name": "test",
"email": "test@gmail.com",
"password": "password"
}
- **Request Headers**
> None
- **Success Response:**
**Status: `200 OK`**
- **Sample Content:**
```json
{
"Message": "User created!",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.
eyJpZCI6IjVmNTc2OTlmM2U4NjFjMDAxNzBhNTFhMSIsImlhdCI6MTU5OTU2NDE5MSwiZXhwIjoxNTk5NjUwNTkxfQ.
Hkp5ruXBMYdJ4pYdQCIJbKfB5PU6hdss5lEXehtNGUc"
}
- Error Response
{
"status": 422,
"message": "an error occured"
}
Logs in a single user in the application.
Endpoint | Method | Params | Data-type |
---|---|---|---|
/api/v1/auth/login | None | None |
- Request Body
{
"username": "test",
"password": "password"
}
Endpoint | Method | Params | Data-type |
---|---|---|---|
/home |
GET | None |
string |
##Response Hello from Toyota
Creates an order to the database.
Endpoint | Method | Params | Data-type |
---|---|---|---|
/api/v1/parcels/users |
POST | None |
string |
Views the order.
Endpoint | Method | Params | Data-type |
---|---|---|---|
/api/v1/parcels/users |
GET | required |
string |
Gets specific order from the database.
Endpoint | Method | Params | Data-type |
---|---|---|---|
/api/v1/parcels/:name/parcels |
GET | None |
None |
Endpoint | Method | Params | Data-type |
---|---|---|---|
`/api/v1/parcels/users/:parcelid/destination | PATCH | required |
string |
Endpoint | Method | Params | Data-type |
---|---|---|---|
`/api/v1/parcels/users/:parcelid/cancel | DELETE | required |
string |
- Bato Alvin