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 --prodto install dependencies - create a .env file from the .env.sample file and fill in the necessary environment variables
- run
npm run buildto build the project and then runnpm startto 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:migrateORnpm 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:stringNote the necessary--used in the second method usingnpm. It is needed to separate the params passed tonpmcommand itself and params passed to the script. ref -
To undo migrations, run
npx sequelize-cli db:migrate:undoORnpm 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:allORnpm run seed -
To rollback and delete seed data run
npx sequelize-cli db:seed:undoORnpm 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 devThe 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 buildBabel then transpiles your ES6+ files to ES5 for environment compatibility