Skip to content

Commit cde8baf

Browse files
committed
Initial commit.
0 parents  commit cde8baf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+21492
-0
lines changed

.editorconfig

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# EditorConfig helps developers define and maintain consistent
2+
# coding styles between different editors and IDEs
3+
# editorconfig.org
4+
5+
root = true
6+
7+
[*]
8+
9+
# Change these settings to your own preference
10+
indent_style = space
11+
indent_size = 2
12+
13+
# We recommend you to keep these unchanged
14+
end_of_line = lf
15+
charset = utf-8
16+
trim_trailing_whitespace = true
17+
insert_final_newline = true
18+
19+
[*.md]
20+
trim_trailing_whitespace = false

.env.example

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
DB_HOST=127.0.0.1
2+
DB_USER=user
3+
DB_PASSWORD=secret
4+
DB_DATABASE=mydatabase
5+
DB_PORT=3306
6+
7+
ENGINE_SERVICE_NAME=my-service
8+
ENGINE_API_KEY=keyhere

.gitignore

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.env
2+
node_modules
3+
dist
4+
build/*
5+
src/resolvers-types.ts
6+
logs
7+
yarn-error.log
8+
public.key
9+
private.key

.prettierrc.json

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"arrowParens": "always",
3+
"bracketSpacing": true,
4+
"htmlWhitespaceSensitivity": "css",
5+
"insertPragma": false,
6+
"jsxBracketSameLine": false,
7+
"jsxSingleQuote": false,
8+
"parser": "typescript",
9+
"proseWrap": "always",
10+
"requirePragma": false,
11+
"semi": true,
12+
"singleQuote": false,
13+
"trailingComma": "all"
14+
}

.vscode/extensions.json

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
// See http://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
3+
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
4+
5+
// List of extensions which should be recommended for users of this workspace.
6+
"recommendations": [
7+
"apollographql.vscode-apollo",
8+
"esbenp.prettier-vscode",
9+
"visualstudioexptteam.vscodeintellicode",
10+
"eg2.vscode-npm-script",
11+
"christian-kohler.npm-intellisense",
12+
"christian-kohler.path-intellisense",
13+
"philfontaine.autolaunch",
14+
"mikestead.dotenv"
15+
],
16+
// List of extensions recommended by VS Code that should not be recommended for users of this workspace.
17+
"unwantedRecommendations": [
18+
19+
]
20+
}

.vscode/launch.json

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"type": "node",
9+
"request": "attach",
10+
"restart": true,
11+
"name": "Attach to remote",
12+
"port": 9229,
13+
"auto": true
14+
}
15+
]
16+
}

.vscode/settings.json

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"files.exclude": {
3+
"**/.git": true, // this is a default value
4+
"**/.DS_Store": true, // this is a default value
5+
6+
"**/node_modules": true, // this excludes all folders
7+
// named "node_modules" from
8+
// the explore tree
9+
},
10+
11+
"git.autofetch": true,
12+
13+
"editor.formatOnSave": false,
14+
"[typescript]": {
15+
"editor.formatOnSave": true
16+
},
17+
18+
"typescript.preferences.quoteStyle": "double"
19+
}

README.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
## A TypeScript GraphQL API using GraphQL Modules with code auto-generation.
2+
3+
4+
Install
5+
```npm install```
6+
7+
Run the server:
8+
```npm run start```
9+
10+
Run the server in development mode:
11+
```npm run dev```

apollo.config.js

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
require('dotenv').config();
2+
3+
const { ENGINE_SERVICE_NAME } = process.env;
4+
5+
module.exports = {
6+
service: {
7+
name: ENGINE_SERVICE_NAME,
8+
localSchemaFile: './build/schema.graphql'
9+
},
10+
};

codegen.json

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"schema": "./src/schema.ts",
3+
"overwrite": true,
4+
"require": [
5+
"ts-node/register/transpile-only",
6+
"tsconfig-paths/register"
7+
],
8+
"generates": {
9+
"./src/resolvers-types.ts": {
10+
"config": {
11+
"mappers": {
12+
"User": "@models#UserDbObject",
13+
"UserList": "@models#UserListDb",
14+
"EmailAddress": "@models#EmailAddressDbObject"
15+
}
16+
},
17+
"plugins": [
18+
"typescript-common",
19+
"typescript-server",
20+
"typescript-resolvers"
21+
]
22+
}
23+
}
24+
}

knexfile.ts

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
require('dotenv').config();
2+
3+
const {
4+
DB_HOST,
5+
DB_USER,
6+
DB_PASSWORD,
7+
DB_DATABASE,
8+
DB_PORT,
9+
} = process.env;
10+
11+
const defaults = {
12+
client: 'mysql',
13+
connection: {
14+
host: DB_HOST,
15+
user: DB_USER,
16+
password: DB_PASSWORD,
17+
database: DB_DATABASE,
18+
port: DB_PORT,
19+
},
20+
};
21+
22+
const config = {
23+
development: {
24+
...defaults,
25+
debug: true,
26+
useNullAsDefault: true,
27+
},
28+
29+
production: {
30+
...defaults,
31+
debug: false,
32+
useNullAsDefault: true,
33+
},
34+
};
35+
36+
module.exports = config;
37+
export default config;

migrations/20180617203030_users.ts

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import * as Knex from "knex";
2+
import dbSchemaAddTimestamps from '../src/utils/dbSchemaAddTimestamps';
3+
import { USER_ROLES } from '../src/constants';
4+
5+
exports.up = async function (knex: Knex): Promise<any> {
6+
await knex.schema.createTable('users', (table) => {
7+
table.increments('id').notNullable().primary();
8+
table.uuid('uuid').notNullable().unique();
9+
table.string('firstName');
10+
table.string('lastName');
11+
table.string('password');
12+
table.enum('roleType', USER_ROLES);
13+
table.index(['roleType']);
14+
dbSchemaAddTimestamps({ knex, table });
15+
});
16+
17+
await knex.schema.createTable('emails', (table) => {
18+
table.increments('id').notNullable().primary();
19+
table.uuid('userId').notNullable();
20+
table.string('email', 100).notNullable();
21+
table.boolean('verified').notNullable().defaultTo(false);
22+
table.boolean('primary').notNullable().defaultTo(false);
23+
table.unique(['email', 'verified']);
24+
dbSchemaAddTimestamps({ knex, table });
25+
});
26+
27+
await knex.schema.createTable('tokens', (table) => {
28+
table.increments('id').notNullable().primary();
29+
table.uuid('userId').notNullable();
30+
table.string('token', 255).notNullable();
31+
table.boolean('blacklisted').notNullable().defaultTo(false);
32+
table.unique(['userId', 'token']);
33+
dbSchemaAddTimestamps({ knex, table });
34+
});
35+
};
36+
37+
exports.down = async function (knex: Knex): Promise<any> {
38+
await knex.schema.dropTableIfExists('users');
39+
await knex.schema.dropTableIfExists('emails');
40+
await knex.schema.dropTableIfExists('tokens');
41+
};

nodemon.json

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"watch": [
3+
"src/",
4+
"knexfile.ts",
5+
".env"
6+
],
7+
"env": {
8+
"NODE_ENV": "development"
9+
}
10+
}

0 commit comments

Comments
 (0)