View all files | ||||
Minimal Lightweight starter kit for developing API Backend server based on Node.js, MySQL along with built-in support for Socket.io and Redis.
This project mainly depends on Express and Knex (for MySQL). Other dependencies such as for Redis and Socket.io can be commented in package.json if you do not need them.
Just clone the repo and open the project in any code editor such as Visual Studio/Webstorm. Run npm/yarn install to install the dependencies and then start your server using npm start:
Once you run npm start, your server will start at http://localhost:1337. The sample api included with this project will be available at POST http://localhost:1337/v1/api-one. You can test out the api using either CURL or Postman.
All configurations related to MySQL/Redis/Socket.io are present in config/env/development.js(or production.js). Simply replace the configs with actual values corresponding to yout MySQL/Redis servers.
For using Socket.io server, you need to uncomment the relevant code in app.js.
The sample api code is present in src/models and src/controllers. Once you have went through the sample api code, you can remove the ModelOne.js and ModelControllerOne.js files and add your own files. You can also install useful packages like Async to better structure your apis.
For all other files, you can check out the directory structure and associated comments to know the use case for each file/folder. You will also find relevant comments in each file. It is suggested that you go through each file once to understand its relevance to the project.
The easiest way to deploy the server is by running npm start. If you need to use a cluster, you can install pm2 and deploy it using pm2 in cluster mode. You can read about pm2 here.
You can deploy the server on any platform such as AWS or DigitalOcean.
Everyone is welcome to contribute. Please start by checking out the list of open issues. Will also appreciate any help in improving the Readme section.
node-api-starter-kit is released under the MIT license.