This repository is a simple Express MVC structure from scratch.
- Clone the repo from Github.
- Run
npm install
oryarn install
. - Create .env from .env.sample file and add your DB parameters. Don't delete the .sample file, it must be kept.
DB_HOST=your_db_host
DB_PORT=your_db_port
DB_USER=your_db_user
DB_PASSWORD=your_db_password
DB_NAME=your_db_name
- Adapt database.sql with your own tables. Import the script in your SQL server. You can do it manually or run migrate script (either using
npm run migrate
oryarn run migrate
). - Start the server in dev mode with
npm run dev
oryarn run dev
. This will runindex.js
using nodemon. - Go to
localhost:5000
with your favorite browser. - From this starter kit, create your own web application.
If you develop on Windows, you should edit you git configuration to change your end of line rules with this command :
git config --global core.autocrlf true
An example (a basic list of items) is provided (you can load the database.sql file in a test database). The accessible URLs are :
- Home page: GET localhost:5000/
- Item browse: GET localhost:5000/items
- Item read: GET localhost:5000/items/:id
- Item edit: PUT localhost:5000/items/:id
- Item add: POST localhost:5000/items
- Item deletion: DELETE localhost:5000/items/:id
You can find all these routes declared in the file src/router.js
. You can add your own new routes, controllers and models.