Skip to content

Commit 7dc897f

Browse files
Jaime Salas ZancadaJaime Salas Zancada
authored andcommitted
added start code for github actions
1 parent acca8ce commit 7dc897f

Some content is hidden

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

73 files changed

+34262
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# DATA_BASE
2+
DATA_BASE_ACTIVE=false
3+
DATABASE_PORT=5432
4+
DATABASE_HOST=localhost
5+
DATABASE_NAME=hangman_db
6+
DATABASE_USER=postgres
7+
DATABASE_PASSWORD=postgres
8+
DATABASE_POOL_MIN=2
9+
DATABASE_POOL_MAX=10
10+
# HTTP_SERVER
11+
PORT=3000
12+
HOST=0.0.0.0
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
node_modules
2+
3+
.env
4+
.env.test
5+
6+
dist
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"printWidth": 120,
3+
"tabWidth": 2,
4+
"endOfLine": "lf",
5+
"trailingComma": "all",
6+
"singleQuote": true,
7+
"arrowParens": "always"
8+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#------------------------------------------------------------------------------
2+
# -- builder
3+
#------------------------------------------------------------------------------
4+
FROM node:lts-alpine as builder
5+
6+
WORKDIR /app
7+
COPY . .
8+
9+
RUN npm ci
10+
RUN npm run build
11+
12+
#------------------------------------------------------------------------------
13+
# -- app
14+
#------------------------------------------------------------------------------
15+
FROM node:lts-alpine as app
16+
17+
WORKDIR /app
18+
COPY --from=builder /app/dist .
19+
COPY package.json .
20+
COPY package-lock.json .
21+
22+
ENV NODE_ENV=production
23+
24+
RUN npm install
25+
26+
27+
CMD ["npm", "start"]
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/**
2+
* @param { import("knex").Knex } knex
3+
* @returns { Promise<void> }
4+
*/
5+
exports.up = function (knex) {
6+
return knex.schema
7+
.createTable('players', function (table) {
8+
table.increments();
9+
table.string('name').notNullable();
10+
table.timestamp('created_at').defaultTo(knex.fn.now());
11+
table.timestamp('updated_at').defaultTo(knex.fn.now());
12+
})
13+
.createTable('words', function (table) {
14+
table.increments();
15+
table.string('entry').notNullable();
16+
table.enu('word_category', ['clothes', 'sports', 'vehicles'], { useNative: true, enumName: 'category' });
17+
table.timestamp('created_at').defaultTo(knex.fn.now());
18+
table.timestamp('updated_at').defaultTo(knex.fn.now());
19+
})
20+
.createTable('games', function (table) {
21+
table.increments();
22+
table.integer('player_id').references('id').inTable('players');
23+
table.integer('word_id').references('id').inTable('words');
24+
table.enu('game_state', ['not_started', 'started', 'finished'], { useNative: true, enumName: 'progress' });
25+
table.timestamp('created_at').defaultTo(knex.fn.now());
26+
table.timestamp('updated_at').defaultTo(knex.fn.now());
27+
});
28+
};
29+
30+
/**
31+
* @param { import("knex").Knex } knex
32+
* @returns { Promise<void> }
33+
*/
34+
exports.down = function (knex) {
35+
36+
};
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
require('dotenv').config({
2+
path: '.env.test'
3+
});
4+
5+
module.exports = {
6+
testEnvironment: 'node',
7+
roots: ['<rootDir>/src'],
8+
testMatch: ['**/?(*.)+(test).+(ts|js)'],
9+
transform: {
10+
'^.+\\.ts$': 'ts-jest',
11+
},
12+
};
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
require('dotenv').config({
2+
path: '.env.test'
3+
});
4+
5+
module.exports = {
6+
testEnvironment: 'node',
7+
roots: ['<rootDir>/src'],
8+
testMatch: ['**/?(*.)+(spec).+(ts|js)'],
9+
transform: {
10+
'^.+\\.ts$': 'ts-jest',
11+
},
12+
};
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
require('dotenv').config();
2+
3+
module.exports = {
4+
5+
development: {
6+
client: 'postgresql',
7+
connection: {
8+
port: process.env.DATABASE_PORT,
9+
host: process.env.DATABASE_HOST,
10+
database: process.env.DATABASE_NAME,
11+
user: process.env.DATABASE_USER,
12+
password: process.env.DATABASE_PASSWORD
13+
},
14+
pool: {
15+
min: +process.env.DATABASE_POOL_MIN,
16+
max: +process.env.DATABASE_POOL_MAX
17+
},
18+
migrations: {
19+
directory: './db/migrations',
20+
tableName: 'knex_migrations'
21+
},
22+
seeds: {
23+
directory: './db/seeds'
24+
}
25+
},
26+
27+
production: {
28+
client: 'postgresql',
29+
connection: {
30+
database: 'my_db',
31+
user: 'username',
32+
password: 'password'
33+
},
34+
pool: {
35+
min: 2,
36+
max: 10
37+
},
38+
migrations: {
39+
tableName: 'knex_migrations'
40+
}
41+
}
42+
43+
};
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"watch": ["src", ".env"],
3+
"ext": "ts",
4+
"ignore": ["src/**/*.test.ts"],
5+
"exec": "ts-node ./src/app.ts"
6+
}

0 commit comments

Comments
 (0)