Skip to content

Commit

Permalink
v1.0 Deploy to production (#55)
Browse files Browse the repository at this point in the history
* --no-amend

* --no-amend

* --no-amend

* --no-amend

* --no-amend

* --no-amend

* --no-amend

* --no-amend

* --no-amend

* --no-amend

* --no-amend

* --no-amend

* --no-amend

* --no-amend

* --no-amend

* --no-amend

* --no-amend

* --no-amend

* --no-amend

* --no-amend

* --no-amend

* --no-amend

* --no-amend

* --no-amend

* --no-amend

* feature
-creates Industries, Mentors and Mentees Table

* --no-amend

* user router created

Co-authored-by: rui <[email protected]>

* User Auth By Social Media

* --no-amend

* --no-amend

* --no-amend

* Added Db configuration and connection changes

* --no-amend

* --no-amend

* --no-amend

* Start adding passport local strategy

Co-authored-by: Damola Adewunmi <[email protected]>
Co-authored-by: Ikechukwu Eze <[email protected]>

* Rename files and fix router to pass tests

* ft/create-Mentoring_types-Pivot-Tables
-created Mentoring_types, Mentees_choices Mentor_chioces Table
-implemented many to many relationship between Mentor Mentee and Mentorying_types

* --no-amend

* local database connected

* Deleted user-router file

* --no-amend

* --no-amend

* --no-amend

* Deleted UserAuth file

* Deleted mentor test

* --no-amend

* refactored mentor file to use response helper

* Created response helper

* Added Create User profile endpoint

* Commented out the as keyword from mentor and mentee choices

* --no-amend

* Added editUserProfile feature

* Add bcrypt and add signup endpoint

* --no-amend

* added tests

* --no-amend

* --no-amend

* --no-amend

* --no-amend

* --no-amend

* --no-amend

* --no-amend

* --no-amend

* --no-amend

* --no-amend

* --no-amend

* refactored updateuserProfile

* ft/seed-users-table
added demo-user username password first_name last_name password and email

* --no-amend

* --no-amend

* wrote some tests for update profile endpoint

* --no-amend

* --no-amend

* --no-amend

* --no-amend

* --no-amend

* --no-amend

* added mentor controllers

* Add OS specific exclusions

Based on https://www.gitignore.io/api/linux,macos,windows

* Added test for mentorRoute

* commented out mentor test file

* removed console.log

* delete mentor test file

* refactored code

* Add login functionality and work on social auth

* fixed some bugs on mentors and users endpoint

* no-amend

* Fix signup and login endpoints

Co-authored-by: Nmeregini Vincent <[email protected]>

* Add signup validator

* Replace bcrypt with bcryptjs

* Remove extra console.log

* Remove console;log

* fixed getUsers endpoint

* turned sequelize scripts to use locally installed executables

* Tested getallUsers endpoint

* viewUserProfile fixed. bug

* Test for viewUserProfile  passed

* Add comment to mentors controller

* Add initial implementation of Github strategy

Co-authored-by: Nmeregini Vincent <[email protected]>

* Changed  status codes

* made changes as requested

* damola changes

* GetAllMentors debugged and tested

* Add logout endpoint

* no_amend

* makeUserMentor feature debugged and fixed, tests implemented and passing

* deleted comment as requested

* All tests passed. Made changes as requested by Vincent

* damola changes

* Added condition to test

* Complete github signup/login

* Remove unused logout endpoint

* Cleanup code

* mentee routes written

* Endpoints tested on Insomnia. Working as expected

* Added standard tests for mentee endpoints

* ft/mentoryinTypes-techName
creates techJob table and seeds mentoryingType, techJob table

* added niyon logo to mail

* Made changes as requested by Rui

* Made changes requested by Rui

* getallJobs written and tested

* Attach token to response when signing up

* getMentoringTypes written

* Refactored mentoringTypes

* Add test

* add autocomplete and corresponding tests

* removed sum function in index

* Remove bio requirement

* removed test for unecessary sum function

* ft/socialMedia
-created social media Table
-seeded social media Table
-created endpoint to add a user's social media handle

* skipped autocomplete test as it takes so much time

* Fix bug on update profile endpoint

* ft/socialMedia
-created social media Table
-seeded social media Table
-created endpoint to add a user's social media handle

* update user password endpoint

* tests pass with new account

* add more waiting time to image upload test

* no-amend

* skipped image upload test

* update with development

* wip

* returns unique locations

* removed babel-jest and resolved requested changes on the PR

* Find or create location endpoint written

* refined get user by username data

* Made changes to test files

* changed expected test result

* no_amend

* Made the changes as requested

* no-amend

* Changed validation on location model

* Removed  auth protection from locatiom route

* modified the data that gets returned when fetching all users

* Added some more endpoints

* uncommented line

* Refactored user profile update

* made small changes

* Made changes  as requested by Rui

* Fixed validation error on Location

* Add Mentee and Mentor to getUserByUsername

* Add Mentee and Mentor to getAllUsers

* Change token expiration to 14 days
  • Loading branch information
iykekings authored Sep 6, 2019
1 parent e817bfc commit cc5000e
Show file tree
Hide file tree
Showing 82 changed files with 5,699 additions and 667 deletions.
57 changes: 52 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,80 @@
version: 2
jobs:
build:
working_directory: ~/repo
docker:
# specify the version you desire here
- image: circleci/node:10.16.0

environment:
PGHOST: localhost
PGUSER: postgres
NODE_ENV: test
DIALECT: postgres
DATABASE_URL: "postgres://postgres:postgres@localhost:5432/population_m_s_test"

- image: circleci/postgres:11
environment:
POSTGRES_USER: postgres
POSTGRES_DB: population_m_s_test
DIALECT: postgres
POSTGRES_PASSWORD: postgres
# Specify service dependencies here if necessary
# CircleCI maintains a library of pre-built images
# documented at https://circleci.com/docs/2.0/circleci-images/
# - image: circleci/mongo:3.4.4

working_directory: ~/repo


steps:
- checkout

# Download and cache dependencies
# # Download and cache dependencies
- restore_cache:
keys:
- v1-dependencies-{{ checksum "package.json" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-

- run: yarn install
- run:
npm install

- run:
name: Waiting for PostgreSQL to start
command: |
for i in `seq 1 10`;
do
nc -z localhost 5432 && echo Success && exit 0
echo -n .
sleep 2
done
echo Failed waiting for Postgres && exit 1
# - run:
# name: INSTALL PG CLIENT
# command: sudo apt install -y postgresql-client || true
- run: sudo apt-get update
- run: sudo apt install -y postgresql-client || true
# - run: createdb population-m-s-test
- run:
name: Set up DB
command: |
psql -h localhost -p 5432 -c 'drop database if exists population_m_s_test;' -U postgres
psql -h localhost -p 5432 -c 'create database population_m_s_test;' -U postgres
psql -h localhost -p 5432 -c "CREATE USER postgresql WITH PASSWORD 'postgres';" -U postgres
npx sequelize db:migrate --url "postgres://postgres:postgres@localhost:5432/population_m_s_test"
npx sequelize db:seed:undo:all --url "postgres://postgres:postgres@localhost:5432/population_m_s_test"
npx sequelize db:seed:all --url "postgres://postgres:postgres@localhost:5432/population_m_s_test"
# - run:
# name: "Run Jest and Collect Coverage Reports"
# command: jest --collectCoverage=true
# - store_artifacts:
# path: coverage

- save_cache:
paths:
- node_modules
key: v1-dependencies-{{ checksum "package.json" }}

# run tests!
- run: yarn test
# - run: npm run testcircleci
- run: npm run test-ci
2 changes: 2 additions & 0 deletions .coveralls.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
service_name: circle-ci
repo_token: a6qP3UeAT9QnLIDNtZkEjQuAjTz607lHP
1 change: 0 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
module.exports = {
env: {
browser: true,
commonjs: true,
es6: true,
node: true,
Expand Down
43 changes: 43 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,42 @@ pids
*.seed
*.pid.lock

# Linux
*~
.fuse_hidden*
.directory
.Trash-*
.nfs*

# macOS
.DS_Store
.AppleDouble
.LSOverride
Icon
._*
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

# Windows
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db
*.stackdump
[Dd]esktop.ini
$RECYCLE.BIN/
*.lnk

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

Expand Down Expand Up @@ -60,3 +96,10 @@ typings/
# next.js build output
.next
# .vscode/launch.json

# Local Database
# database/
test.js

# intellij config files
.idea
8 changes: 8 additions & 0 deletions .sequelizerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const path = require('path')

module.exports = {
config: path.resolve('./database/config', 'config.js'),
'models-path': path.resolve('./database/models'),
'seeders-path': path.resolve('./database/seeders'),
'migrations-path': path.resolve('./database/migrations'),
}
6 changes: 2 additions & 4 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [

{
"type": "node",
"request": "launch",
"name": "Launch Program",
"name": "Debug",
"program": "${workspaceFolder}/index.js"
},
{
Expand Down
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"editor.formatOnSave": true
}

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![Coverage Status](https://coveralls.io/repos/github/labseu2-niyon/backend/badge.svg?branch=master)](https://coveralls.io/github/labseu2-niyon/backend?branch=master)
[![Coverage Status](https://coveralls.io/repos/github/labseu2-niyon/backend/badge.svg?branch=development)](https://coveralls.io/github/labseu2-niyon/backend?branch=development) [![CircleCI](https://circleci.com/gh/labseu2-niyon/backend.svg?style=svg)](https://circleci.com/gh/labseu2-niyon/backend)

🚫 Note: All lines that start with 🚫 are instructions and should be deleted before this is posted to your portfolio. This is intended to be a guideline. Feel free to add your own flare to it.

Expand Down
Binary file added __test__/assests/contact.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions __test__/autocomplete.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const request = require('supertest');
const server = require('../server');

describe('Autocomplete /api/autocomplete/:place', () => {
it('should return an array of possible location', async done => {
try {
const res = await request(server).get('/api/autocomplete/enugu');
expect(res.body.data.length).toBeGreaterThan(0);
expect(res.status).toBe(200);
done();
} catch (err) {
done(`failed: ${JSON.stringify(err)}`);
}
});
it('should return an empty array for unknown location', async done => {
try {
const res = await request(server).get(
'/api/autocomplete/xyrgvfggyeye633d'
);
expect(res.body.data).not.toBeUndefined();
expect(res.status).toBe(200);
done();
} catch (err) {
done(`failed: ${JSON.stringify(err)}`);
}
});
});
33 changes: 33 additions & 0 deletions __test__/country.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
const request = require('supertest');
const server = require('../server');

describe('GET /api/countries/countries', () => {
it('should return a 201 after getting all countries', () => {
return request(server)
.get('/api/countries/countries')
.then(res => {
expect(res.status).toBe(200);
expect(res.body.data).toHaveLength(2);
});
});
});

describe('GET /api/countries/:country/cities', () => {
it('should return a 200 if city exists', () => {
return request(server)
.get('/api/countries/Nigeria/cities')
.then(res => {
expect(res.status).toBe(200);
expect(res.body.data).toHaveLength(2);
});
});

it('should return a 200 if city dont exists', () => {
return request(server)
.get('/api/countries/canada/cities')
.then(res => {
expect(res.status).toBe(200);
expect(res.body.data).toBe('No cities saved in the country');
});
});
});
2 changes: 1 addition & 1 deletion __test__/db.test.js → __test__/db.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const NiyonDB = require('../conn');
const NiyonDB = require('../database/models');

afterAll(() => {
NiyonDB.close();
Expand Down
33 changes: 0 additions & 33 deletions __test__/index.test.js

This file was deleted.

13 changes: 13 additions & 0 deletions __test__/jobs.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const request = require('supertest');
const server = require('../server');

describe('Get /jobs/all', () => {
it('should return a 200 code', async () => {
return request(server)
.get('/api/jobs/all')
.then(res => {
expect(res.status).toBe(200);
expect(res.type).toEqual('application/json');
});
});
});
25 changes: 25 additions & 0 deletions __test__/location.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const request = require('supertest');
const server = require('../server');

describe('POST /api/location', () => {
it('should return a 400 if country name is not provided', () => {
return request(server)
.post('/api/location/getLocation')
.send({})
.then(res => {
expect(res.status).toBe(400);
expect(res.body.message.cityName[0]).toBe(
'The cityName field is required.'
);
});
});
it('should return a 201 if location was created', () => {
return request(server)
.post('/api/location/getLocation')
.send({ cityName: 'kaduna', countryName: 'Nigeria' })
.then(res => {
expect(res.status).toBe(201);
expect(res.body.data).toBe(3);
});
});
});
Loading

0 comments on commit cc5000e

Please sign in to comment.