syntax enforcing
This commit is contained in:
+14
-14
@@ -1,9 +1,9 @@
|
|||||||
import { Kysely, PostgresDialect } from "kysely";
|
import { Kysely, PostgresDialect } from 'kysely'
|
||||||
import { Pool } from "pg";
|
import { Pool } from 'pg'
|
||||||
import migrateToLatest from "./migrations";
|
import migrateToLatest from './migrations'
|
||||||
import Database, { KillTable } from "./model";
|
import Database, { KillTable } from './model'
|
||||||
|
|
||||||
const migration = migrateToLatest();
|
const migration = migrateToLatest()
|
||||||
// You'd create one of these when you start your app.
|
// You'd create one of these when you start your app.
|
||||||
const db = new Kysely<Database>({
|
const db = new Kysely<Database>({
|
||||||
// Use MysqlDialect for MySQL and SqliteDialect for SQLite.
|
// Use MysqlDialect for MySQL and SqliteDialect for SQLite.
|
||||||
@@ -12,10 +12,10 @@ const db = new Kysely<Database>({
|
|||||||
host: process.env.POSTGRES_HOST,
|
host: process.env.POSTGRES_HOST,
|
||||||
database: process.env.POSTGRES_DATABASE,
|
database: process.env.POSTGRES_DATABASE,
|
||||||
user: process.env.POSTGRES_USER,
|
user: process.env.POSTGRES_USER,
|
||||||
password: process.env.POSTGRES_PASSWORD,
|
password: process.env.POSTGRES_PASSWORD
|
||||||
}),
|
})
|
||||||
}),
|
})
|
||||||
});
|
})
|
||||||
|
|
||||||
export async function CreateKillRecord({
|
export async function CreateKillRecord({
|
||||||
server,
|
server,
|
||||||
@@ -24,12 +24,12 @@ export async function CreateKillRecord({
|
|||||||
weapon,
|
weapon,
|
||||||
map,
|
map,
|
||||||
distance,
|
distance,
|
||||||
date,
|
date
|
||||||
}: KillTable) {
|
}: KillTable) {
|
||||||
await db
|
await db
|
||||||
.insertInto("kill")
|
.insertInto('kill')
|
||||||
.values({ server, attacker, victim, weapon, map, distance, date })
|
.values({ server, attacker, victim, weapon, map, distance, date })
|
||||||
.execute();
|
.execute()
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
async function demo() {
|
async function demo() {
|
||||||
@@ -57,6 +57,6 @@ async function demo() {
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
export default async function ready(): Promise<Kysely<Database>> {
|
export default async function ready(): Promise<Kysely<Database>> {
|
||||||
await migration;
|
await migration
|
||||||
return db;
|
return db
|
||||||
}
|
}
|
||||||
|
|||||||
+17
-17
@@ -1,23 +1,23 @@
|
|||||||
import * as dotenv from "dotenv";
|
import * as dotenv from 'dotenv'
|
||||||
dotenv.config();
|
dotenv.config()
|
||||||
import express from "express";
|
import express from 'express'
|
||||||
import client from "./client";
|
import client from './client'
|
||||||
import db from "./db/db";
|
import db from './db/db'
|
||||||
import server from "./server";
|
import server from './server'
|
||||||
|
|
||||||
console.log("dotenv");
|
console.log('dotenv')
|
||||||
console.log(db);
|
console.log(db)
|
||||||
|
|
||||||
const app = express();
|
const app = express()
|
||||||
const port = 3000;
|
const port = 3000
|
||||||
|
|
||||||
app.get("/", (req, res) => {
|
app.get('/', (req, res) => {
|
||||||
res.send("Hello World!");
|
res.send('Hello World!')
|
||||||
});
|
})
|
||||||
|
|
||||||
app.use("/register", server);
|
app.use('/register', server)
|
||||||
app.use("/api", client);
|
app.use('/api', client)
|
||||||
|
|
||||||
app.listen(port, () => {
|
app.listen(port, () => {
|
||||||
console.log(`Example app listening on port ${port}`);
|
console.log(`Example app listening on port ${port}`)
|
||||||
});
|
})
|
||||||
|
|||||||
+9
-9
@@ -1,10 +1,10 @@
|
|||||||
import { Router } from "express";
|
import { Router } from 'express'
|
||||||
const router = Router();
|
const router = Router()
|
||||||
//auth middleware
|
//auth middleware
|
||||||
router.post("/*", (req, res, next) => {
|
router.post('/*', (req, res, next) => {
|
||||||
next();
|
next()
|
||||||
});
|
})
|
||||||
router.post("/*", (req, res, next) => {
|
router.post('/*', (req, res, next) => {
|
||||||
next();
|
next()
|
||||||
});
|
})
|
||||||
export default router;
|
export default router
|
||||||
|
|||||||
Reference in New Issue
Block a user