Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade depdencies #249

Open
wants to merge 15 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
77 changes: 77 additions & 0 deletions .env.postgres
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#
# APPLICATION
#
APP_NAME=express-typescript-boilerplate
APP_SCHEMA=http
APP_HOST=localhost
APP_PORT=5000
APP_ROUTE_PREFIX=/api
APP_BANNER=true

#
# LOGGING
#
LOG_LEVEL=debug
LOG_OUTPUT=dev

#
# PostgreSQL DATABASE
#
TYPEORM_CONNECTION=postgres
TYPEORM_HOST=postgres
TYPEORM_PORT=5432
TYPEORM_USERNAME=admin
TYPEORM_PASSWORD=admin
TYPEORM_DATABASE=my_database
TYPEORM_SYNCHRONIZE=false
TYPEORM_LOGGING=error
TYPEORM_LOGGER=advanced-console

#
# MySQL DATABASE
#
# TYPEORM_CONNECTION=mysql
# TYPEORM_HOST=localhost
# TYPEORM_PORT=3306
# TYPEORM_USERNAME=root
# TYPEORM_PASSWORD=root
# TYPEORM_DATABASE=my_database
# TYPEORM_SYNCHRONIZE=false
# TYPEORM_LOGGING=error
# TYPEORM_LOGGER=advanced-console

#
# PATH STRUCTRUE
#
TYPEORM_MIGRATIONS=src/database/migrations/**/*.ts
TYPEORM_MIGRATIONS_DIR=src/database/migrations
TYPEORM_ENTITIES=src/api/models/**/*.ts
TYPEORM_ENTITIES_DIR=src/api/models
CONTROLLERS=src/api/controllers/**/*Controller.ts
MIDDLEWARES=src/api/middlewares/**/*Middleware.ts
INTERCEPTORS=src/api/interceptors/**/*Interceptor.ts
SUBSCRIBERS=src/api/subscribers/**/*Subscriber.ts
RESOLVERS=src/api/resolvers/**/*Resolver.ts

#
# GraphQL
#
GRAPHQL_ENABLED=true
GRAPHQL_ROUTE=/graphql
GRAPHQL_EDITOR=true

#
# Swagger
#
SWAGGER_ENABLED=true
SWAGGER_ROUTE=/swagger
SWAGGER_USERNAME=admin
SWAGGER_PASSWORD=1234

#
# Status Monitor
#
MONITOR_ENABLED=true
MONITOR_ROUTE=/monitor
MONITOR_USERNAME=admin
MONITOR_PASSWORD=1234
2 changes: 1 addition & 1 deletion .env.test
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ LOG_OUTPUT=dev
# DATABASE
#
TYPEORM_CONNECTION=sqlite
TYPEORM_DATABASE=./mydb.sql
TYPEORM_DATABASE=mydb.sql
TYPEORM_LOGGING=error
TYPEORM_LOGGER=advanced-console

Expand Down
5 changes: 4 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,8 @@
},
"importSorter.generalConfiguration.sortOnBeforeSave": true,
"files.trimTrailingWhitespace": true,
"editor.formatOnSave": false
"editor.formatOnSave": false,
"cSpell.words": [
"Metadatas"
]
}
30 changes: 17 additions & 13 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
{
"version": "0.1.0",
"version": "2.0.0",
"command": "npm",
"isShellCommand": true,
"suppressTaskName": true,
"tasks": [
{
// Build task, Cmd+Shift+B
// "npm run build"
"taskName": "build",
"isBuildCommand": true,
"label": "build",
"type": "shell",
"args": [
"run",
"build"
]
],
"problemMatcher": [],
"group": {
"_id": "build",
"isDefault": false
}
},
{
// Test task, Cmd+Shift+T
// "npm test"
"taskName": "test",
"isTestCommand": true,
"label": "test",
"type": "shell",
"args": [
"test"
]
],
"problemMatcher": [],
"group": {
"_id": "test",
"isDefault": false
}
}
]
}
27 changes: 27 additions & 0 deletions .vscode/tasks.json.old
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"version": "0.1.0",
"command": "npm",
"isShellCommand": true,
"suppressTaskName": true,
"tasks": [
{
// Build task, Cmd+Shift+B
// "npm run build"
"taskName": "build",
"isBuildCommand": true,
"args": [
"run",
"build"
]
},
{
// Test task, Cmd+Shift+T
// "npm test"
"taskName": "test",
"isTestCommand": true,
"args": [
"test"
]
}
]
}
10 changes: 5 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
FROM node:alpine
FROM node:17-alpine3.14

# Update apk
RUN apk add --update --no-cache curl py-pip

# Create work directory
WORKDIR /usr/src/app

# Install runtime dependencies
RUN npm install yarn -g

# Copy app source to work directory
COPY . /usr/src/app

# Install app dependencies
RUN yarn install

# Build and run the app
CMD npm start serve
CMD yarn start setup & npm start serve
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
environment:
nodejs_version: "8"
nodejs_version: "14"
DB_TYPE: "sqlite"
DB_DATABASE: "./mydb.sql"
DB_LOGGING: false
Expand Down
37 changes: 15 additions & 22 deletions commands/seed.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import chalk from 'chalk';
import commander from 'commander';
import * as commander from 'commander';
import G from 'glob';
import * as path from 'path';
import {
loadConnection, loadEntityFactories, loadSeeds, runSeed, setConnection
} from 'typeorm-seeding';
import { createConnection, getConnectionOptions, runSeeder, useSeeding } from 'typeorm-seeding';

// Cli helper
commander
Expand All @@ -16,16 +15,6 @@ commander
.option('--config <file>', 'path to your ormconfig.json file (must be a json)')
.parse(process.argv);

// Get cli parameter for a different factory path
const factoryPath = (commander.factories)
? commander.factories
: 'src/database/factories';

// Get cli parameter for a different seeds path
const seedsPath = (commander.seeds)
? commander.seeds
: 'src/database/seeds/';

// Get a list of seeds
const listOfSeeds = (commander.run)
? commander.run.map(l => l.trim()).filter(l => l.length > 0)
Expand All @@ -35,11 +24,14 @@ const listOfSeeds = (commander.run)
const run = async () => {
const log = console.log;

let factoryFiles;
let seedFiles;
let seedFiles: string[];
let factories: string[];

try {
factoryFiles = await loadEntityFactories(factoryPath);
seedFiles = await loadSeeds(seedsPath);
const connectionOptions = await getConnectionOptions();
seedFiles = G.sync(connectionOptions.seeds[0], {absolute: true});
factories = G.sync(connectionOptions.factories[0], {absolute: true});

} catch (error) {
return handleError(error);
}
Expand All @@ -52,12 +44,13 @@ const run = async () => {
// Status logging to print out the amount of factories and seeds.
log(chalk.bold('seeds'));
log('🔎 ', chalk.gray.underline(`found:`),
chalk.blue.bold(`${factoryFiles.length} factories`, chalk.gray('&'), chalk.blue.bold(`${seedFiles.length} seeds`)));
chalk.blue.bold(`${factories.length} factories`, chalk.gray('&'), chalk.blue.bold(`${seedFiles.length} seeds`)));

// Get database connection and pass it to the seeder
try {
const connection = await loadConnection();
setConnection(connection);
const ma = await getConnectionOptions();
await useSeeding();
await createConnection(ma);
} catch (error) {
return handleError(error);
}
Expand All @@ -70,7 +63,7 @@ const run = async () => {
className = className.split('-')[className.split('-').length - 1];
log('\n' + chalk.gray.underline(`executing seed: `), chalk.green.bold(`${className}`));
const seedFileObject: any = require(seedFile);
await runSeed(seedFileObject[className]);
await runSeeder(seedFileObject[className]);
} catch (error) {
console.error('Could not run seed ', error);
process.exit(1);
Expand Down
42 changes: 42 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
version: "3.9"

services:
web:
build: .
links:
- postgres
ports:
- "5000:5000"
- "9229:9229"
depends_on:
- postgres
stdin_open: true
env_file: ./.env.postgres
tty: true
container_name: web-server

postgres:
image: postgres:14
command: postgres -c shared_preload_libraries=pg_stat_statements -c pg_stat_statements.track=all -c max_connections=200
environment:
POSTGRES_DB: my_database
POSTGRES_USER: admin
POSTGRES_PASSWORD: admin
ports:
- "5432:5432"
container_name: postgres


pgadmin:
container_name: pgadmin_container
image: dpage/pgadmin4
logging:
driver: none
links:
- postgres
environment:
PGADMIN_DEFAULT_EMAIL: [email protected]
PGADMIN_DEFAULT_PASSWORD: admin
PGADMIN_CONFIG_SERVER_MODE: 'False'
ports:
- "5601:80"
Loading