-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 10744bd
Showing
8 changed files
with
1,295 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"singleQuote": true, | ||
"semi": false, | ||
"tabWidth": 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"name": "api", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"start": "node dist/index.js", | ||
"dev": "nodemon src/index.ts", | ||
"codegen": "kysely-codegen --dialect postgres" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": { | ||
"cors": "^2.8.5", | ||
"express": "^4.18.2", | ||
"kysely": "^0.26.3", | ||
"pg": "^8.11.3", | ||
"socket.io": "^4.7.2", | ||
"ts-node": "^10.9.1" | ||
}, | ||
"devDependencies": { | ||
"@types/express": "^4.17.18", | ||
"@types/pg": "^8.10.4", | ||
"dotenv": "^16.3.1", | ||
"kysely-codegen": "^0.10.1", | ||
"nodemon": "^3.0.1", | ||
"typescript": "^5.2.2", | ||
"zod": "^3.22.4" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { Kysely, PostgresDialect } from 'kysely' | ||
import { DB } from 'kysely-codegen' | ||
import { Pool } from 'pg' | ||
import * as dotenv from 'dotenv' | ||
|
||
dotenv.config() | ||
|
||
export const db = new Kysely<DB>({ | ||
dialect: new PostgresDialect({ | ||
pool: new Pool({ | ||
connectionString: process.env.DATABASE_URL, | ||
}), | ||
}), | ||
// log(event) { | ||
// if (event.level === 'query') { | ||
// console.log(event.query.sql) | ||
// console.log(event.query.parameters) | ||
// } | ||
// }, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { io } from '../index' | ||
|
||
export function startSocket() { | ||
io.on('connection', (socket) => { | ||
console.log(socket.id) | ||
|
||
socket.on('message', (socket) => { | ||
console.log(socket) | ||
io.emit('message', 'test') | ||
}) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import express, { Express } from 'express' | ||
import { createServer } from 'http' | ||
import { Server } from 'socket.io' | ||
import * as dotenv from 'dotenv' | ||
import { startSocket } from './controllers/SocketController' | ||
dotenv.config() | ||
|
||
// routers | ||
|
||
const app = express() | ||
const httpServer = createServer(app) | ||
const io = new Server(httpServer) | ||
|
||
app.use(express.urlencoded({ extended: false })) | ||
app.use(express.json()) | ||
|
||
app.use('/hello', (req, res) => { | ||
res.send('hello') | ||
}) | ||
|
||
startSocket() | ||
|
||
httpServer.listen(3000, () => console.log('Server is running on port 3000')) | ||
|
||
export { io } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"target": "esnext", | ||
"moduleResolution": "node", | ||
"esModuleInterop": true, | ||
"sourceMap": true, | ||
"outDir": "dist", | ||
"allowJs": true, | ||
"lib": ["dom", "es6"], | ||
"baseUrl": "./src", | ||
"paths": { | ||
"@/*": [ | ||
"./*" | ||
] | ||
} | ||
}, | ||
"exclude": [ | ||
"node_modules", | ||
"dist" | ||
], | ||
"include": [ | ||
"src/**/*.ts", | ||
"tests/**/*.spec.ts" | ||
], | ||
"files": [ | ||
"src/index.ts" | ||
] | ||
} |
Oops, something went wrong.