-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: refs #109848 setup base of the project
- Loading branch information
M0Bruno
committed
Jun 28, 2019
0 parents
commit 923fb87
Showing
13 changed files
with
6,248 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
APP_PORT=1337 | ||
APP_PROTOCOL=http | ||
APP_HOST=localhost | ||
|
||
PARSE_APP_NAME=connect | ||
PARSE_APP_ID=1234567890 | ||
PARSE_FILE_KEY=FILE_KEY | ||
PARSE_MASTER_KEY=MASTER_KEY | ||
|
||
MONGO_PORT=27017 | ||
MONGO_HOST=0.0.0.0 | ||
MONGO_USERNAME=connect | ||
MONGO_PASSWORD=connect | ||
MONGO_DB_NAME=connect |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.idea | ||
node_modules/ | ||
yarn-error.log | ||
.history | ||
.env | ||
logs/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
12.5.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Connect | ||
|
||
An open platform to save anonymous data coming from any application using this API | ||
|
||
## Getting Started | ||
|
||
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. | ||
|
||
### Prerequisites | ||
|
||
What things you need to install the software | ||
|
||
``` | ||
node v12.5+ | ||
yarn v1.16+ | ||
docker-compose v1.23+ | ||
``` | ||
|
||
### Installing | ||
|
||
Setup env variable | ||
|
||
``` | ||
cp .env.dist .env | ||
``` | ||
|
||
Edit the .env file to set your custom values. | ||
Then start the docker compose to get a mongo db ready to use | ||
|
||
``` | ||
docker-compose -d up | ||
``` | ||
|
||
The project is ready to run | ||
|
||
``` | ||
yarn start | ||
``` | ||
|
||
### Running the tests | ||
|
||
To run jest tests : | ||
|
||
``` | ||
yarn test | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
version: '3.1' | ||
services: | ||
mongo: | ||
image: mongo:4 | ||
ports: | ||
- ${MONGO_PORT}:27017 | ||
volumes: | ||
- connect-mongo-storage:/data/db | ||
- ./docker/init-mongo.sh:/docker-entrypoint-initdb.d/init-mongo.sh | ||
environment: | ||
MONGO_INITDB_ROOT_USERNAME: ${MONGO_USERNAME} | ||
MONGO_INITDB_ROOT_PASSWORD: ${MONGO_PASSWORD} | ||
MONGO_INITDB_DATABASE: ${MONGO_DB_NAME} | ||
mongo-express: | ||
image: mongo-express | ||
ports: | ||
- 8081:8081 | ||
environment: | ||
ME_CONFIG_MONGODB_ADMINUSERNAME: ${MONGO_USERNAME} | ||
ME_CONFIG_MONGODB_ADMINPASSWORD: ${MONGO_PASSWORD} | ||
node: | ||
image: node:latest | ||
environment: | ||
- DEBUG=connect* | ||
volumes: | ||
- $PWD:/usr/src | ||
working_dir: /usr/src | ||
volumes: | ||
connect-mongo-storage: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
mongo -- "$MONGO_INITDB_DATABASE" <<EOF | ||
var user = '$MONGO_INITDB_ROOT_USERNAME'; | ||
var passwd = '$MONGO_INITDB_ROOT_PASSWORD'; | ||
var admin = db.getSiblingDB('admin'); | ||
admin.auth(user, passwd); | ||
db.createUser({user: user, pwd: passwd, roles: ["readWrite"]}); | ||
EOF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ | ||
"name": "connect", | ||
"version": "1.0.0", | ||
"description": "", | ||
"scripts": { | ||
"start": "node src/index.js", | ||
"tslint.check": "tslint", | ||
"tslint.fix": "tslint --fix", | ||
"prettier.check": "prettier '{src,../common}/**/*.{js}' --list-different", | ||
"prettier.fix": "prettier '{src,../common}/**/*.{js}' --write", | ||
"test": "jest -c jest.config.integration.js --detectOpenHandles --forceExit" | ||
}, | ||
"prettier": { | ||
"singleQuote": true, | ||
"trailingComma": "all", | ||
"semi": true, | ||
"printWidth": 80 | ||
}, | ||
"author": "Matters", | ||
"license": "ISC", | ||
"dependencies": { | ||
"dotenv": "^8.0.0", | ||
"debug": "4.1.1", | ||
"express": "^4.17.1", | ||
"parse-dashboard": "1.3.3", | ||
"parse-server": "3.4.4", | ||
"parse-server-swagger": "0.1.0", | ||
"winston": "^3.2.1" | ||
}, | ||
"devDependencies": { | ||
"jest": "^24.8.0", | ||
"prettier": "^1.18.2", | ||
"tslint": "^5.18.0", | ||
"tslint-config-airbnb": "^5.11.1", | ||
"tslint-config-prettier": "^1.18.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
require('dotenv').config(); | ||
|
||
function testConfig(config, name) { | ||
if ( | ||
(!config && config !== false && config !== 'false') || | ||
(config + '').length <= 0 | ||
) { | ||
throw new Error( | ||
`Undefined config ${name}: ${JSON.stringify(process.env)} `, | ||
); | ||
} | ||
} | ||
|
||
const APP_PORT = process.env.APP_PORT; | ||
testConfig(APP_PORT, 'APP_PORT'); | ||
|
||
const APP_PROTOCOL = process.env.APP_PROTOCOL; | ||
testConfig(APP_PROTOCOL, 'APP_PROTOCOL'); | ||
|
||
const APP_HOST = process.env.APP_HOST; | ||
testConfig(APP_HOST, 'APP_HOST'); | ||
|
||
const PARSE_APP_NAME = process.env.PARSE_APP_NAME; | ||
testConfig(PARSE_APP_NAME, 'PARSE_APP_NAME'); | ||
|
||
const PARSE_APP_ID = process.env.PARSE_APP_ID; | ||
testConfig(PARSE_APP_ID, 'PARSE_APP_ID'); | ||
|
||
const PARSE_FILE_KEY = process.env.PARSE_FILE_KEY; | ||
testConfig(PARSE_FILE_KEY, 'PARSE_FILE_KEY'); | ||
|
||
const PARSE_MASTER_KEY = process.env.PARSE_MASTER_KEY; | ||
testConfig(PARSE_MASTER_KEY, 'PARSE_MASTER_KEY'); | ||
|
||
const MONGO_PORT = process.env.MONGO_PORT; | ||
testConfig(MONGO_PORT, 'MONGO_PORT'); | ||
|
||
const MONGO_HOST = process.env.MONGO_HOST; | ||
testConfig(MONGO_HOST, 'MONGO_HOST'); | ||
|
||
const MONGO_USERNAME = process.env.MONGO_USERNAME; | ||
testConfig(MONGO_USERNAME, 'MONGO_USERNAME'); | ||
|
||
const MONGO_PASSWORD = process.env.MONGO_PASSWORD; | ||
testConfig(MONGO_PASSWORD, 'MONGO_PASSWORD'); | ||
|
||
const MONGO_DB_NAME = process.env.MONGO_DB_NAME; | ||
testConfig(MONGO_DB_NAME, 'MONGO_DB_NAME'); | ||
|
||
module.exports = { | ||
APP_PORT, | ||
APP_PROTOCOL, | ||
APP_HOST, | ||
PARSE_APP_NAME, | ||
PARSE_APP_ID, | ||
PARSE_FILE_KEY, | ||
PARSE_MASTER_KEY, | ||
MONGO_PORT, | ||
MONGO_HOST, | ||
MONGO_USERNAME, | ||
MONGO_PASSWORD, | ||
MONGO_DB_NAME, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
const { APP_PORT } = require('./config'); | ||
const express = require('express'); | ||
const parseApi = require('./middleware/parse'); | ||
const parseDashboard = require('./middleware/parseDashboard'); | ||
|
||
const app = express(); | ||
|
||
// Serve the Parse API at /parse URL prefix | ||
app.use('/parse', parseApi); | ||
app.use('/dashboard', parseDashboard); | ||
|
||
const port = APP_PORT || 1337; | ||
|
||
app.listen(port, function() { | ||
console.log('parse-server-example running on port ' + port + '.'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const { | ||
MONGO_DB_NAME, | ||
MONGO_HOST, | ||
MONGO_USERNAME, | ||
MONGO_PASSWORD, | ||
MONGO_PORT, | ||
PARSE_APP_NAME, | ||
PARSE_APP_ID, | ||
PARSE_FILE_KEY, | ||
PARSE_MASTER_KEY, | ||
} = require('./../config'); | ||
|
||
var ParseServer = require('parse-server').ParseServer; | ||
|
||
module.exports = new ParseServer({ | ||
databaseURI: `mongodb://${MONGO_USERNAME}:${MONGO_PASSWORD}@${MONGO_HOST}:${MONGO_PORT}/${MONGO_DB_NAME}`, | ||
cloud: './src/parse/cloud/main.js', | ||
appId: PARSE_APP_ID, | ||
fileKey: PARSE_FILE_KEY, | ||
masterKey: PARSE_MASTER_KEY, | ||
appName: PARSE_APP_NAME, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
var ParseDashboard = require('parse-dashboard'); | ||
const { | ||
APP_PORT, | ||
APP_PROTOCOL, | ||
APP_HOST, | ||
PARSE_APP_NAME, | ||
PARSE_APP_ID, | ||
PARSE_MASTER_KEY, | ||
} = require('./../config'); | ||
|
||
module.exports = new ParseDashboard({ | ||
apps: [ | ||
{ | ||
serverURL: `${APP_PROTOCOL}://${APP_HOST}:${APP_PORT}/parse`, | ||
appId: PARSE_APP_ID, | ||
masterKey: PARSE_MASTER_KEY, | ||
appName: PARSE_APP_NAME, | ||
}, | ||
], | ||
}); |
Empty file.
Oops, something went wrong.