Unislove backend containing All list API's and server hosted in port <3002>
These instructions will give you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on deploying the project on a live system.
- Node.js (atleast-- node: 14.17.0, npm: 16.14.13)
- Typescript
- Express
- MySQL
Requirements for the software and other tools to build, test and push
-
You need to install MySql
- For Windows
- Install mySql and set following environment variable C:\Program Files\mysql\10\bin
- For Ubuntu
- Installation sudo apt update sudo apt-get install mysql
- For Windows
-
create
.env
from.env-example
. then, update database credentials to make connection successfully. if the.env
file gets failed to load, it can load the default values frombase.config.ts
which is under/src/configs/
. -
install all dependencies need for application to run locally
Pre-Note: After cloning the codebase, make sure
DB_MIGRATE_FORCE
andDB_MIGRATE_ALTER
are seated asfalse
in prod to prevent the data loses.DB_MIGRATE_FORCE=true
can drop existed tables and recreate them.DB_MIGRATE_ALTER=true
can alter existed tables instead of dropping them. it can help to prevent loosing data somewhat. but not relay on this always.-
git clone https://github.com/Inqui-Lab-Foundation/unisolve-be.git
-
yarn install
||npm install
-
yarn start:dev
||npm start:dev
This will start the application in development mode -
yarn start:prod
||npm start:prod
This will start the application and run on port 3002 -
Pre-Note:: you must build the project once using
npm run build
before executing the below command -
Note: For the first time, if you want to create all tables in the selected database, it is recommended to run
npm run migrate up
from route directory.
-
-
if required, you can change port and others details in
.env
file. if the.env
file gets failed to load, it can load the default values frombase.config.ts
which is under/src/configs/
.
unisolve-be # Project route directory
├──keys # Secret keys directory
│ ├──jwt.key # JWT secret key
│ └──jwt.pub # JWT public encryption key
├──src # Source directory
│ ├──configs # Application one place configurations directory
│ │ ├──base.config.ts # Base configuration file to carry defaults for `.env` file
│ │ ├──constenants.ts # Application constants file to carry application wide constants
│ │ ├──speeches.config.ts # Speech file to carry out all hardcoded messages
│ │ ├──whildcardRoutes.config.ts # Wildcard routes to list authentication free routes
│ │ ├──dynamicForm.ts # Dynamic form fields list to be used in forms
│ │ └──signUp.json # Dynamically generated Sign up form fields
│ ├──controllers # Controllers directory
│ │ ├──base.controller.ts # Base controller can be extended by other feature controllers to carry standers CRUD operations
│ │ ├──crud.controller.ts # CRUD controller is responsible for standers CRUD endpoints for all models
│ │ └── **feature_controllers
│ ├──models # Models directory can hold all ORM models
│ │ └── **feature_models
│ ├──services # Services directory can hold all services
│ │ ├──crud.service.ts # CRUD service is responsible for standers CRUD operations in CRUD controller
│ │ └── **feature_services
│ ├──middlewares # Middlewares directory can hold all application middlewares
│ │ ├──errorHandler.middleware.ts # Error handler middleware to handle errors
│ │ ├──healthCheck.middleware.ts # Health check middleware to check if the application running health
│ │ ├──routeProtection.middleware.ts # Route protector middleware to protect from unauthorized access
│ │ ├──validation.middleware.ts # Validation middleware to validate request body
│ │ └── **feature_middlewares
│ ├──utils # Utility directory
│ │ ├──exceptions # Exceptions directory can hold all custom exceptions
│ │ │ ├──http.exception.ts # Http exception class
│ │ │ └──**feature_exceptions
│ │ ├──jwt.util.ts # JWT utility to generate and verify JWT tokens
│ │ ├──logit.util.ts # Logit utility to log messages into console or a file and DB
│ │ ├──validate_env.util.ts # Validate environment can validate env variables and fill with default values if failed
│ │ └──**feature_utils
│ ├──validations # Validations directory can hold all validations for all endpoint data inputs
│ ├──interfaces # Interfaces directory can hold all interfaces for any strictured classes
│ ├──docs # Documentation directory to keep swagger documentation
│ ├──migrations # Migrations directory to hold all DB migrations
│ ├──logs # Logs directory to keep day wise logs
│ ├──app.ts # Main application file
│ └──index.ts # Main application entry point
├──package.json # application metadata
├──.env # Application environment variables
├──.env-example # Application environment variables template
├──.sequelizerc # Sequelize configuration file
└──Readme.md # Application readme file
- CRUD operations for student
- Authentication for student
- REST API Request object validations - Basic
- Error Logs
- Setup docs
to create a new empty migation file you can run
npm run migrate create -- --name=name_you_want_for_migration_file.ts
upon calling the above command a new file will be generated at src/migrations/migrations/ folder with name xxxxtimestampxxx.name_you_want_for_migration_file.ts once you have generated migration file you can call
Note:: you must build the project once before executing the below command
npm run migrate up
command will execute all pending migrations.
npm run down -- --name=name_of_migration_file_you_wish_to_revert.ts
command will revert particular migration mentioned in --name
- Use underscore_names instead of CamelCase
- Table names should be plural
- Spell out id fields (item_id instead of id)
- Don't use ambiguous column names
- When possible, name foreign key columns the same as the columns they refer to
yarn run test
|| npm run test
testing with converge of the files
yarn run test:coverage
|| npm run test:coverage
- JWT login
- Unit Testing
- Postman collections
- Improve request Object Validations
- Improve Error Messages for request failures
- Swagger Docs
- Security
- SQL Database
- Hosting
Explain what these tests test and why
Give an example
Checks if the best practices and the right coding style has been used.
Es-lint
Add additional notes to deploy this on a live system
- Contributor Covenant - Used for the Code of Conduct
- Creative Commons - Used to choose the license
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
We use Semantic Versioning for versioning. For the versions available, see the tags on this repository.
- Pradeep Gandla
- Harishkumar
- Aman Satija
- Vamshi
See also the list of contributors who participated in this project.
This project is licensed under the CC0 1.0 Universal Creative Commons License - see the LICENSE.md file for details
- Hat tip to anyone whose code is used
- Inspiration
- etc