HidayJS is open-source pure backend RESTful API template using ExpressJS based on clean MVC (Model View Controllers) architecture.
- ExpressJS version ^4.19.2
- Sequelize version ^6.37.1
- Sequelize-cli version ^6.6.2
- Nodemon version ^3.1.0
- Dotenv version ^16.4.5
- Supported dialects: mssql, mariadb, mysql, oracle, postgres, db2 and sqlite.
This stack is still under development and possible to change at any time.
Dillinger requires Node.js to run. In this example below we want to use npm and npx, if you use yarn or others it doesn't matter just adjust it.
- Clone this Repository
git clone https://github.com/hidayatur90/hd-template- Install the dependencies and devDependencies and start the server.
cd hd-template
npm i- Rename .env.example to .env and update the file.
PORT=your_port
DB_NAME=your_database_name
DB_USER=your_database_user
DB_PASSWORD=your_database_password
DB_HOST=your_database_host
DB_DIALECT=your_database_dialect
SECRET_KEY=your_secret_key_here*adjust .env to what you will use
- Set your dialect
In this template the default dialect that use is MySQL, if you want to change it just install the library and adjust it. For example you want to use PostgreeSQL you can do...
npm install pgand change DB_DIALECT on your .env file to your own dialect.
- Migrate the database and seed it using sequelize-cli
npx sequelize-cli db:migrate
npx sequelize-cli seed:generate- Finally, run the HidayJS
npm run devOn this HidayJS template we use JWT auth, so if you want to try it make sure you must authenticate and set your token to the header.
| header | value |
|---|---|
| Content-Type | application/json |
| authorization | Bearer your_jwt_token |
HidayJS its just MVC template for ExpressJS so you can improve that with your requirement apps. For example you can improve with Swagger to make the Documentation API, you can change the default auth to OAuth, etc. You can use every sequelize-cli command like make models, seeder or migrate. For example you can use this command to make new models call Employee
npx sequelize-cli model:generate --name Employee --attributes fist_name:string,last_name:string