Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
de8ab16
test config
Client-Z Nov 22, 2019
5d88b1c
change config
Client-Z Nov 22, 2019
ebe7e05
test deploy.sh
Client-Z Nov 22, 2019
50ae3c8
test deploy job
Client-Z Nov 22, 2019
f8c2f31
fix config.yml
Client-Z Nov 22, 2019
e17c39f
change config.yml
Client-Z Nov 22, 2019
22b32a6
fix deploy.sh
Client-Z Nov 22, 2019
5cb1d86
a little fix
Client-Z Nov 22, 2019
53f909f
Merge branch 'feature/hw-11' into feature/hw-12
Client-Z Nov 22, 2019
8d55803
[docs] - add some schemas, auth paths have been done
Client-Z Nov 23, 2019
77b4aa6
[docs] - add docs for post and comment routes, fix a bug with comment…
Client-Z Nov 23, 2019
12c3bb0
[deploy] - add npm script for mogrations and remove deploy.sh from gi…
Client-Z Nov 24, 2019
9e0517b
test ci/cd commit
Client-Z Nov 24, 2019
7604947
[swagger] - add docs for users and profile routes
Client-Z Nov 26, 2019
aff945e
[swagger] - fees and oauth routes
Client-Z Nov 26, 2019
be8c931
test setup with error
Client-Z Nov 26, 2019
18ef32a
add some mocks
Client-Z Nov 26, 2019
60f3a33
fix mongoose problem
Client-Z Nov 26, 2019
46b115f
test environment was setuped
Client-Z Nov 27, 2019
7aab51f
[tests] - test for logOut
Client-Z Nov 27, 2019
2a8cb2f
[tests] - toggle on tests in circleci config
Client-Z Nov 27, 2019
49725e9
[tests] - fix gitignore
Client-Z Nov 27, 2019
81861c2
[tests] - variables
Client-Z Nov 27, 2019
36eb6fb
[tests] - variables
Client-Z Nov 27, 2019
c7ed5fb
[tests] - fix vars
Client-Z Nov 27, 2019
80ded21
[tests] - fix mongoConnection setup
Client-Z Nov 27, 2019
7bf7a10
[tests] - change ioredis mock
Client-Z Nov 27, 2019
5c48a9a
[tests] - test - vars
Client-Z Nov 27, 2019
06f2663
[tests] - add google-cloud mock
Client-Z Nov 27, 2019
82e9b20
[tests] - google-cloud mock
Client-Z Nov 27, 2019
8a354c9
[tests] - google-cloud mock
Client-Z Nov 27, 2019
c3adaf1
[tests] - test vars
Client-Z Nov 27, 2019
90991c4
[tests]
Client-Z Nov 27, 2019
3e67bc4
fix content field for articles
Client-Z Nov 27, 2019
47bac02
[articles] - fix loading
Client-Z Nov 28, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .circleci/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FRONTEND_URL=https://test.com

DATABASE_URL=mysql://user:password@localhost:3306/database
CONNECTION_STR=mongodb://user:password@localhost:27017/database

SESSION_SECRET=test
EMAIL_SECRET=test
60 changes: 60 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
version: 2.1
jobs:
build:
docker:
- image: circleci/node:12
- image: circleci/mysql:5.7
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: database
MYSQL_USER: user
MYSQL_PASSWORD: password
- image: mongo:latest
environment:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: password
MONGO_INITDB_DATABASE: database
working_directory: ~/build
steps:
- checkout
- run:
name: Install MongoDB Shell
command: |
curl https://www.mongodb.org/static/pgp/server-4.2.asc | sudo apt-key add -
echo "deb http://repo.mongodb.org/apt/debian stretch/mongodb-org/4.2 main" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.2.list
sudo apt-get update
sudo apt-get install -y mongodb-org-shell
- run:
name: Configure MongoDB
command: mongo -u root -p password < ./mongo-init.js
- restore_cache:
keys:
- v1-dependencies-{{ checksum "package.json" }}
- v1-dependencies-
- run:
name: Install
command: npm install
- save_cache:
paths:
- node_modules
key: v1-dependencies-{{ checksum "package.json" }}
- run:
name: Test
command: npm run test #-circleci
deploy:
docker:
- image: circleci/node:12
steps:
- run: sudo apt-get install sshpass -y
- run: sshpass -p ${PASSWORD} ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o PreferredAuthentications=password denis@35.225.244.173 './deploy.sh'
workflows:
version: 2
build-and-deploy:
jobs:
- build
- deploy:
requires:
- build
filters:
branches:
only: feature/hw-12 # master, develop
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
node_modules
.env
/.env
service-key.json
gcs-key.json
gcs-key.json
deploy.sh
11 changes: 11 additions & 0 deletions __mocks__/@google-cloud/storage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* eslint-disable */

class Storage {
constructor() {
this.bucket = jest.fn(() => {})
}
bucket() {
jest.fn(() => {})
}
}
module.exports = { Storage }
4 changes: 4 additions & 0 deletions __mocks__/ioredis.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/* eslint-disable */
const redis = require('redis-mock')

module.exports = jest.fn(() => redis.createClient())
31 changes: 31 additions & 0 deletions __mocks__/passport-facebook.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
const { Strategy } = require('passport')
const faker = require('faker')

class MockStrategy extends Strategy {
constructor(options, verify) {
super()
this.user = {
id: faker.random.number(),
name: {
givenName: faker.name.firstName(),
familyName: faker.name.lastName()
},
_json: {
email: faker.internet.email()
}
}
this.name = 'facebook'
this.options = options
this.verify = verify
}

authenticate(req) {
if (req.query.code) return this.redirect('/')
this.verify(null, null, this.user, (err, user) => {
if (err) return this.fail(err)
return this.success(user)
})
}
}

module.exports = MockStrategy
29 changes: 29 additions & 0 deletions __mocks__/passport-google-oauth20.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const { Strategy } = require('passport')
const faker = require('faker')

class MockStrategy extends Strategy {
constructor(options, verify) {
super()
this.user = {
id: faker.random.number(),
_json: {
given_name: faker.name.firstName(),
family_name: faker.name.lastName(),
email: faker.internet.email()
}
}
this.name = 'google'
this.options = options
this.verify = verify
}

authenticate(req) {
if (req.query.code) return this.redirect('/')
this.verify(null, null, this.user, (err, user) => {
if (err) return this.fail(err)
return this.success(user)
})
}
}

module.exports = MockStrategy
7 changes: 7 additions & 0 deletions __mocks__/sharp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const { Transform } = require('stream')

const resize = new Transform({
transform: (chunk, enc, done) => done(null, chunk)
})

module.exports = () => ({ resize: () => resize })
6 changes: 6 additions & 0 deletions __mocks__/stripe.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/* eslint-disable */
class Stripe {}
const stripe = jest.fn(() => new Stripe())

module.exports = stripe
module.exports.Stripe = Stripe
21 changes: 21 additions & 0 deletions __mocks__/winston.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/* eslint-disable */
const winston = {
format: {
combine: jest.fn(),
splat: jest.fn(),
simple: jest.fn()
},
transports: jest.fn(),
createLogger: jest.fn(() => {
return {
info: jest.fn(),
error: jest.fn(),
end: jest.fn()
}
})
}

winston.transports.Console = jest.fn()
winston.transports.MongoDB = jest.fn()

module.exports = winston
Loading