Skip to content

Commit

Permalink
massive upgrade and modernization of infrastructure code.
Browse files Browse the repository at this point in the history
  • Loading branch information
Morgul committed May 19, 2024
1 parent 42da33f commit 178bd7f
Show file tree
Hide file tree
Showing 46 changed files with 812 additions and 604 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ COPY --from=bundle-builder /app/package.json /app/
RUN mkdir /app/db

WORKDIR /app
ADD ./config.yml /app/config.yml
ADD config/local.yml /app/config.yml

VOLUME /app/db

Expand Down
26 changes: 16 additions & 10 deletions config.yml → config/local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,26 @@
# Configuration for RPGKeeper
#-----------------------------------------------------------------------------------------------------------------------

overrideAuth: false
secret: $SESSION_SECRET
key: 'rpgk_session'
auth:
google:
clientID: $CLIENT_ID
clientSecret: $CLIENT_SECRET
# HTTP Server configuration
http:
secure: false,
host: '0.0.0.0'
port: 5678
secure: false

# Database
database:
client: 'better-sqlite3'
client: "better-sqlite3"
connection:
filename: './db/rpgk.db'
filename: "db/rpgk.db"
useNullAsDefault: true

# Authentication configuration
auth:
session:
key: 'rpgk_session'
secret: $SESSION_SECRET
google:
clientID: $CLIENT_ID
clientSecret: $CLIENT_SECRET

#-----------------------------------------------------------------------------------------------------------------------
62 changes: 13 additions & 49 deletions knexfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,63 +2,27 @@
// Knex Migration configuration
//----------------------------------------------------------------------------------------------------------------------

require('ts-node/register');

//----------------------------------------------------------------------------------------------------------------------

// This has to be first, for reasons
import dotenv from 'dotenv';

import knex from 'knex';
import 'dotenv/config';
import configUtil from '@strata-js/util-config';
import type { Knex } from 'knex';

// Managers
import { getConfig } from './src/server/managers/database';
import { ServerConfig } from './src/common/interfaces/config';

// ---------------------------------------------------------------------------------------------------------------------
// Configuration
// ---------------------------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------------------------

dotenv.config();
const env = (process.env.ENVIRONMENT ?? 'local').toLowerCase();
configUtil.load(`./config/${ env }.yml`);

//----------------------------------------------------------------------------------------------------------------------

module.exports = async() =>
{
const db = knex(getConfig());

// When this file is run, it expects the migrations to end in .ts, so accommodate that.
await db('knex_migrations')
.select()
.limit(1)
.then(async() =>
{
await db.update({ name: db.raw('replace(name, \'.js\', \'.ts\')') })
.from('knex_migrations');
})
.catch(async(error) =>
{
if(error.code !== 'SQLITE_ERROR')
{
throw error;
} // end if
});

return {
...getConfig(),
migrations: {
directory: './src/server/knex/migrations',
extension: 'ts',
loadExtensions: [ '.ts' ]
},
seeds: {
directory: './src/server/knex/seeds',
loadExtensions: [ '.ts' ]
}
};
};
module.exports = {
...configUtil.get<ServerConfig>().database ?? {},
migrations: {
directory: './src/server/knex/migrations'
},
seeds: {
directory: './src/server/knex/seeds'
}
} satisfies Knex.Config;

//----------------------------------------------------------------------------------------------------------------------

161 changes: 160 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 178bd7f

Please sign in to comment.