README.md
, .gitignore
, MIT License
.cd
into newly cloned repo, and create and checkout to dev branch
git checkout -b dev
npm init -y
npm install dotenv express jest`
or
npm install cors dotenv express eslint jest supertest pg sequelize sequelize-cli sqlite3
or
npm i base-64 bcrypt cors dotenv express jest pg supertest sequelize sequelize-cli sqlite3
package.json
"init:config": "sequelize init:config",
"db:create": "sequelize db:create"
npm run init:config
config/config.json
file with your username, database name, and make sure to set the dialect to postgres
{
"development": {
"username": "your-username", //Put your username here
"password": "not-necessary-unless-you-add-this-feature",
"database": "your-database-name", //Put your db name here
"host": "127.0.0.1",
"dialect": "postgres" //Defaul mysql, change to postgres
},
"test": {
"username": "root",
"password": null,
"database": "database_test",
"host": "127.0.0.1",
"dialect": "mysql"
},
"production": {
"username": "root",
"password": null,
"database": "database_production",
"host": "127.0.0.1",
"dialect": "mysql"
}
}
npm run db:create
node.yml
, .gitignore
,.eslintrc.json
. (will not use eslintrc.json
for REACT).
cp -r ../seattle-code-javascript-401d53/configs/ .
api-server
and bring them to the root of the new auth-api
reponpm i
AND make sure that all the packages from BOTH package.json files are installed: thses are the packages that need to be added: `npm i cors bcrypt base-64auth
folder (from the auth-server
) into the new repo’s src
foldermodels/index
so we will ned to import users from auth/models
into src/models
// Propose file structure for Lab09
├── .github │ ├── workflows │ │ └── node.yml ├── tests │ ├── auth.test.js (integration test) │ └── server.test.js ├── src │ ├── auth │ │ ├── middleware │ │ │ ├── acl.js │ │ │ ├── basic.js │ │ │ ├── basic.test.js (unit test) │ │ │ └── bearer.js │ │ │ ├── bearer.test.js │ │ ├── models │ │ │ └── users.js │ │ └── routes.js │ ├── error-handlers │ │ ├── 404.js │ │ └── 500.js │ ├── middleware │ │ └── logger.js │ ├── models │ │ ├── blogs │ │ │ └── model.js │ │ ├── data-collections.js │ │ └── index.js │ ├── routes │ │ ├── v1.js │ │ └── v2.js │ └── server.js ├── .eslintrc.json ├── .gitignore ├── index.js ├── package.json └── README.md
api-server
, and bring them to the root of the new auth-api
reponpm i
AND make sure that all the packages from BOTH package.json files are installed: these are the packages that need to be added: npm i cors bcrypt base-64 jsonwebtoken
api-server
portionauth
folder (from the auth-server
) into the new repo’s src
foldermodels/index.js
, so will need import users from auth/models
into src/models
Comment this in when you want to clear the DB
async function initializeDatabase() {
try {
// Synchronize the Regions model with the database table
await sequelizedDatabase.sync({ force: true });
console.log('All models were synchronized successfully');
} catch (error) {
console.error('Error occurred while syncing all models.', error);
}
}
initializeDatabase();