Provide TypeORM config in code
This commit is contained in:
parent
36c8598c3b
commit
85e9f19a63
|
@ -5,3 +5,4 @@ out/
|
||||||
*.pem
|
*.pem
|
||||||
*.db
|
*.db
|
||||||
*.swp
|
*.swp
|
||||||
|
.idea/
|
||||||
|
|
29
lib/index.ts
29
lib/index.ts
|
@ -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();
|
||||||
|
|
||||||
|
|
|
@ -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"
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue