SGS Backend Development Quality Assurance Guideline
General
- Write clean codes, delete all non-usable codes
- Comment your codes
- Use meaningful names to name your variables
- The project files are already set, you follow the project concept
- All schema properties must start with a lowercase
- The naming convention is lowercase
- All model must record created and modified timestamp
- You have to use proper pagination with Mongoose aggregate
- We prefer you to make more use of aggregate
Documentation
We use Postman for documentation. Each of the application screens will be a folder in the postman collection and the endpoints for each screen will be added as request routes in the folders
Request URL Structure
We maintain this request structure in the overall project:
host:port/dir/version/platform/model/operation
For instance:
Login url should be:
http://localhost:1048/api/v1/ {mobile or web}users/login
Response Structure
All response must follow this structure
status_code: the status code
message: human-readable message
data: response data
req: Request body when available
Response Code Rules
200 OK
Indicates that request has succeeded.
201 Created
Indicates that request has succeeded and a new resource has been created as a result.
400 Error
Indicates that the request has an error.
401 Unauthorized
Indicates that the request requires user authentication information. The client MAY repeat the request with a suitable Authorization header field
500 Internal Server Error
The server encountered an unexpected condition which prevented it from fulfilling the request.
Folder setup
.env file
This contains all the environmental variables
mobile
All the controller files for each screens on the mobile are here
web
All the controller files for each screens on the web are here
models
All the model files are here
db
The database connection setup are configured here
routes
All the routes are setup here
utils
All the utility files are setup here, including the jwt etc
middleware
All the middleware functions alike auth, authorization, validation etc are setup here.
validations
All the validation files are here
Validations
Validation is done using Joi. Basic setup and implementation is done already, so you just implement the validation on the model you are working on.