Provide TypeORM config in code

This commit is contained in:
Shadowfacts 2019-08-17 15:25:19 -04:00
parent 36c8598c3b
commit 85e9f19a63
Signed by untrusted user: shadowfacts
GPG Key ID: 94A5AB95422746E5
3 changed files with 28 additions and 26 deletions

1
.gitignore vendored
View File

@ -5,3 +5,4 @@ out/
*.pem *.pem
*.db *.db
*.swp *.swp
.idea/

View File

@ -10,6 +10,8 @@ import validateHttpSig from "./activitypub/middleware/http-signature";
//import sqlite3 from "sqlite3"; //import sqlite3 from "sqlite3";
import "reflect-metadata"; import "reflect-metadata";
import { createConnection} from "typeorm"; import { createConnection} from "typeorm";
import { promises as fs } from "fs";
import * as path from "path";
//createConnection().then(async connection => { //createConnection().then(async connection => {
@ -47,10 +49,33 @@ async function generate(): Promise<Page[]> {
(async () => { (async () => {
const app = express(); const app = express();
app.use(morgan("dev")) app.use(morgan("dev"));
app.use(bodyParser.json({ type: "application/activity+json" })); app.use(bodyParser.json({ type: "application/activity+json" }));
const connection = await createConnection(); const connection = await createConnection({
"type": "postgres",
"host": "localhost",
"port": 5432,
"username": "blog",
"password": "blog",
"database": "blog",
"synchronize": true,
"logging": true,
"entities": [
path.join(__dirname, "entity/**/*.{ts,js}")
],
"migrations": [
path.join(__dirname, "migration/**/*.{ts,js}")
],
"subscribers": [
path.join(__dirname, "subscriber/**/*.{ts,js}")
],
"cli": {
"entitiesDir": "lib/entity",
"migrationsDir": "lib/migration",
"subscribersDir": "lib/subscriber"
}
});
const posts = await generate(); const posts = await generate();

View File

@ -1,24 +0,0 @@
{
"type": "postgres",
"host": "localhost",
"port": 5432,
"username": "blog",
"password": "blog",
"database": "blog",
"synchronize": true,
"logging": true,
"entities": [
"built/entity/**/*.js"
],
"migrations": [
"built/migration/**/*.js"
],
"subscribers": [
"built/subscriber/**/*.js"
],
"cli": {
"entitiesDir": "lib/entity",
"migrationsDir": "lib/migration",
"subscribersDir": "lib/subscriber"
}
}