move backend from status-affiliate-backend repo

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2020-11-09 21:12:20 +01:00
parent bad41cc5c1
commit 97b0230081
No known key found for this signature in database
GPG Key ID: 4EF064D0E6D63020
22 changed files with 10708 additions and 4 deletions

116
.gitignore vendored
View File

@ -1,7 +1,115 @@
node_modules/
############################
# OS X
############################
.DS_Store
.AppleDouble
.LSOverride
Icon
.Spotlight-V100
.Trashes
._*
############################
# Linux
############################
*~
############################
# Windows
############################
Thumbs.db
ehthumbs.db
Desktop.ini
$RECYCLE.BIN/
*.cab
*.msi
*.msm
*.msp
############################
# Packages
############################
*.7z
*.csv
*.dat
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
*.zip
*.com
*.class
*.dll
*.exe
*.o
*.seed
*.so
*.swo
*.swp
*.swn
*.swm
*.out
*.pid
############################
# Logs and databases
############################
.tmp
*.log
*.sql
*.sqlite
*.sqlite3
############################
# Misc.
############################
*#
ssl
.idea
nbproject
backend/public/
############################
# Node.js
############################
lib-cov
lcov.info
pids
logs
results
node_modules
.node_history
*.map
build/*
.DS_Store
node_modules
build
############################
# Tests
############################
testApp
coverage
############################
# Strapi
############################
.env
license.txt
exports
.cache
build

16
backend/.editorconfig Normal file
View File

@ -0,0 +1,16 @@
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[{package.json,*.yml}]
indent_style = space
indent_size = 2
[*.md]
trim_trailing_whitespace = false

2
backend/.env.example Normal file
View File

@ -0,0 +1,2 @@
HOST=0.0.0.0
PORT=1337

3
backend/.eslintignore Normal file
View File

@ -0,0 +1,3 @@
.cache
build
**/node_modules/**

27
backend/.eslintrc Normal file
View File

@ -0,0 +1,27 @@
{
"parser": "babel-eslint",
"extends": "eslint:recommended",
"env": {
"commonjs": true,
"es6": true,
"node": true,
"browser": false
},
"parserOptions": {
"ecmaFeatures": {
"experimentalObjectRestSpread": true,
"jsx": false
},
"sourceType": "module"
},
"globals": {
"strapi": true
},
"rules": {
"indent": ["error", 2, { "SwitchCase": 1 }],
"linebreak-style": ["error", "unix"],
"no-console": 0,
"quotes": ["error", "single"],
"semi": ["error", "always"]
}
}

View File

@ -0,0 +1,52 @@
{
"routes": [
{
"method": "GET",
"path": "/responses",
"handler": "response.find",
"config": {
"policies": []
}
},
{
"method": "GET",
"path": "/responses/count",
"handler": "response.count",
"config": {
"policies": []
}
},
{
"method": "GET",
"path": "/responses/:id",
"handler": "response.findOne",
"config": {
"policies": []
}
},
{
"method": "POST",
"path": "/responses",
"handler": "response.create",
"config": {
"policies": []
}
},
{
"method": "PUT",
"path": "/responses/:id",
"handler": "response.update",
"config": {
"policies": []
}
},
{
"method": "DELETE",
"path": "/responses/:id",
"handler": "response.delete",
"config": {
"policies": []
}
}
]
}

View File

@ -0,0 +1,8 @@
'use strict';
/**
* Read the documentation (https://strapi.io/documentation/v3.x/concepts/controllers.html#core-controllers)
* to customize this controller
*/
module.exports = {};

View File

@ -0,0 +1,8 @@
'use strict';
/**
* Read the documentation (https://strapi.io/documentation/v3.x/concepts/models.html#lifecycle-hooks)
* to customize this model
*/
module.exports = {};

View File

@ -0,0 +1,26 @@
{
"kind": "collectionType",
"collectionName": "responses",
"info": {
"name": "response"
},
"options": {
"increments": true,
"timestamps": true,
"draftAndPublish": true
},
"attributes": {
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
},
"email": {
"type": "email"
},
"agreed": {
"type": "boolean"
}
}
}

View File

@ -0,0 +1,8 @@
'use strict';
/**
* Read the documentation (https://strapi.io/documentation/v3.x/concepts/services.html#core-services)
* to customize this service
*/
module.exports = {};

View File

@ -0,0 +1,18 @@
module.exports = ({ env }) => ({
defaultConnection: 'default',
connections: {
default: {
connector: 'bookshelf',
settings: {
client: 'postgres',
host: env('DATABASE_HOST', 'postgres-db'),
port: env.int('DATABASE_PORT', 5432),
database: env('DATABASE_NAME', 'status-affliate'),
username: env('DATABASE_USERNAME', 'status'),
password: env('DATABASE_PASSWORD', 'status1!'),
ssl: env.bool('DATABASE_SSL', false),
},
options: {}
},
},
});

13
backend/config/functions/bootstrap.js vendored Normal file
View File

@ -0,0 +1,13 @@
'use strict';
/**
* An asynchronous bootstrap function that runs before
* your application gets started.
*
* This gives you an opportunity to set up your data model,
* run jobs, or perform some special logic.
*
* See more details here: https://strapi.io/documentation/v3.x/concepts/configurations.html#bootstrap
*/
module.exports = () => {};

View File

@ -0,0 +1,21 @@
'use strict';
/**
* Cron config that gives you an opportunity
* to run scheduled jobs.
*
* The cron format consists of:
* [SECOND (optional)] [MINUTE] [HOUR] [DAY OF MONTH] [MONTH OF YEAR] [DAY OF WEEK]
*
* See more details here: https://strapi.io/documentation/v3.x/concepts/configurations.html#cron-tasks
*/
module.exports = {
/**
* Simple example.
* Every monday at 1am.
*/
// '0 1 * * 1': () => {
//
// }
};

View File

@ -0,0 +1,5 @@
'use strict';
module.exports = async (/* ctx */) => {
// return ctx.notFound('My custom message 404');
};

View File

@ -0,0 +1,8 @@
module.exports = {
//...
settings: {
cors: {
origin: ['*'],
},
},
};

9
backend/config/server.js Normal file
View File

@ -0,0 +1,9 @@
module.exports = ({ env }) => ({
host: env('HOST', '0.0.0.0'),
port: env.int('PORT', 1337),
admin: {
auth: {
secret: env('ADMIN_JWT_SECRET', 'ce1699859d78c90339ef5aba71264456'),
},
},
});

View File

@ -0,0 +1,3 @@
module.exports = {
jwtSecret: process.env.JWT_SECRET || '9eb43a38-161a-4348-a291-a135834b1d1a'
};

BIN
backend/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

37
backend/package.json Normal file
View File

@ -0,0 +1,37 @@
{
"name": "app",
"private": true,
"version": "0.1.0",
"description": "A Strapi application",
"scripts": {
"develop": "strapi develop",
"start": "strapi start",
"build": "strapi build",
"strapi": "strapi"
},
"devDependencies": {},
"dependencies": {
"strapi": "3.2.5",
"strapi-admin": "3.2.5",
"strapi-utils": "3.2.5",
"strapi-plugin-content-type-builder": "3.2.5",
"strapi-plugin-content-manager": "3.2.5",
"strapi-plugin-users-permissions": "3.2.5",
"strapi-plugin-email": "3.2.5",
"strapi-plugin-upload": "3.2.5",
"strapi-connector-bookshelf": "3.2.5",
"knex": "<0.20.0",
"pg": "latest"
},
"author": {
"name": "A Strapi developer"
},
"strapi": {
"uuid": "55455219-b914-437e-b07e-54076bebd74d"
},
"engines": {
"node": ">=10.0.0",
"npm": ">=6.0.0"
},
"license": "MIT"
}

0
backend/public/.gitkeep Normal file
View File

10295
backend/yarn.lock Normal file

File diff suppressed because it is too large Load Diff

37
docker-compose.yml Normal file
View File

@ -0,0 +1,37 @@
version: '3'
services:
backend:
container_name: backend
env_file:
- .env
image: strapi/strapi:3.2.5-node12-alpine
restart: always
environment:
- NODE_ENV=production
- DATABASE_CLIENT=postgres
- DATABASE_HOST=${DATABASE_HOST}
- DATABASE_PORT=${DATABASE_PORT}
- DATABASE_NAME=${DATABASE_NAME}
- DATABASE_USERNAME=${DATABASE_USERNAME}
- DATABASE_PASSWORD=${DATABASE_PASSWORD}
ports:
- 1337:1337
volumes:
- ./backend:/srv/app
- ./build:/srv/app/public
depends_on:
- postgres-db
postgres-db:
container_name: postgres-db
env_file:
- .env
image: postgres:13
restart: always
volumes:
- ./db:/var/lib/postgresql/data
environment:
POSTGRES_USER: ${DATABASE_USERNAME}
POSTGRES_PASSWORD: ${DATABASE_PASSWORD}
POSTGRES_DB: ${DATABASE_NAME}