To run this application, you need to have Node.js, and git(to clone the repo) installed. Then follow the instructions to get it up and running
- clone the repo and cd into the directory using
~> git clone https://github.com/emp-daisy/HelloBooksLib.git
~> cd HelloBooksLib
- run
npm install --prod
to install dependencies - create a .env file from the .env.sample file and fill in the necessary environment variables
- run
npm run build
to build the project and then runnpm start
to start the server - now access the server on the localhost port you specify e.g
localhost:5000 or 127.0.0.1:5000
Now the server will go live and listen for requests
-
In other to run migrations, run
npx sequelize-cli db:migrate
ORnpm run migrate
-
To create a new model/migration, run
npx sequelize-cli model:generate --name <model-name> --attributes <attribute-name>:<attribute-type>
ORnpm run generate:model -- --name <model-name> --attributes <attribute-name>:<attribute-type>
For Examplenpm run generate:model -- --name Todos --attributes title:string
Note the necessary--
used in the second method usingnpm
. It is needed to separate the params passed tonpm
command itself and params passed to the script. ref -
To undo migrations, run
npx sequelize-cli db:migrate:undo
ORnpm run migrate:undo
-
To seed the table with default data, create a seed file as described here and then run
npx sequelize-cli db:seed:all
ORnpm run seed
-
To rollback and delete seed data run
npx sequelize-cli db:seed:undo
ORnpm run seed:undo
To develop the app further, a few handy tools have been put in place such as nodemon and some other dev dependencies.
Access them by starting the server using npm run dev
. But before using the command, make sure to follow the steps below
git clone https://github.com/emp-daisy/HelloBooksLib.git
cd HelloBooksLib/
npm install
npm run dev
The app is written in ES6+ and wired to run ES5 transpiled code in production. To transpile any changes to ES5 run the script shown below
npm run build
Babel then transpiles your ES6+ files to ES5 for environment compatibility