"dependencies": { "bcryptjs": "^2.4.3", "cors": "^2.8.5", "dotenv": "^8.0.0", "express": "^4.17.1", "helmet": "^3.18.0", "jsonwebtoken": "^8.5.1", "knex": "^0.19.1", "morgan": "^1.9.1", "path": "^0.12.7", "pg": "^7.12.1", "unirest": "^0.6.0", "xss": "^1.0.6" }, "devDependencies": { "chai": "^4.2.0", "mocha": "^6.2.0", "nodemon": "^1.19.1", "postgrator-cli": "^3.1.0", "supertest": "^4.0.2" }
This app is written using Node.js and Express.
Authentiation and user endpoints relies on jsonwebtoken and bcryptjs--with sanitization being handled by xss.
The database is written with the assitance of postgresql.
Testing frameworks used are; mocha, chai, and supertest.
External API's are Authentic Jobs API, Github Jobs API, EventBrite API, and Hunter.io API. Unirest was used in the communicating with all external api's.
Complete the following steps to start a new project (NEW-PROJECT-NAME):
- Clone this repository to your local machine
cd
into the cloned repository- Make a fresh start of the git history for this project with
rm -rf .git && git init
- Install the node dependencies
npm install
- Move the example Environment file to
.env
that will be ignored by git and read by the express servermv example.env .env
- Edit the contents of the
package.json
to use NEW-PROJECT-NAME instead of"name": "express-boilerplate",
- Create a local .env.
- Create a local database called jobreel and a test db called jobreel-test and assign the appropriate env variables related to said databases.
- Create and place a JWT auth token in the env for the purpose of the auth endpoints
- Obtain API credentials for Authentic Jobs API and Github Jobs API for the jobs route, Hunter.io on the findcontacts route, and Eventbrite on the eventbrite route. Place credentials in the appropriatee variables in the env.
- Run migrations and seeds for the databasese.
- Run all tests to check they are passing.
Connect to JobReel Client
- Auth: Handles authentification with regards to user logins.
- Companies: DB endpoint for saved companies.
- Contacts: DB endpoint related to saved contacts.
- Eventbrite: External eventbrite api endpoint. Handles OAUTH2 authentication for eventbrite api and related get requests which are handled which are accepted from the client as posts and handled with unirest as get and post requests.
- Events: DB endpoint for saved events related to eventbrite api.
- Findcontacts: External hunter.io api endpiont. Handles requests for professional emails based on search criteria.
- Jobs: External authentic and github jobs endpoint which makes requests for jobs based on location, keyword, and city.
- Middleware: JWT-auth middleware.
- Resources: Stored resources such as books or url's.
- Savedjobs: DB endpoint related to the external jobs api.
- Users: Endpoint for newly registering users.
For using example psql role example-user
:
mv example.env .env
createdb -U example-user jobreel
createdb -U example-user jobreel-test
If your example-user
user has a password be sure to set it in .env
for all appropriate fields. Or if using a different user, update appropriately.
npm install
npm run migrate
env MIGRATION_DB_NAME=jobreel-test npm run migrate
For tests involving time to run properly, configure your Postgres database to run in the UTC timezone.
- Locate the
postgresql.conf
file for your Postgres installation.- E.g. for an OS X, Homebrew install:
/usr/local/var/postgres/postgresql.conf
- E.g. on Windows, maybe:
C:\Program Files\PostgreSQL\11.2\data\postgresql.conf
- E.g on Ubuntu 18.04 probably: '/etc/postgresql/10/main/postgresql.conf'
- E.g. for an OS X, Homebrew install:
- Find the
timezone
line and set it toUTC
:
# - Locale and Formatting -
datestyle = 'iso, mdy'
#intervalstyle = 'postgres'
timezone = 'UTC'
#timezone_abbreviations = 'Default' # Select the set of available time zone
Start the application npm start
Start nodemon for the application npm run dev
Run the tests mode npm test
Run the migrations up npm run migrate
Run the migrations down npm run migrate -- 0