aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElizabeth Hunt <elizabeth.hunt@simponic.xyz>2023-05-31 19:11:57 -0700
committerElizabeth Hunt <elizabeth.hunt@simponic.xyz>2023-06-03 17:47:44 -0700
commit0f5555b92915b175a685a24ade9276d170ae37f5 (patch)
tree78ae08b1aaa0263d012ca4037028a21728179bd6
parent926bebb122ba4226b65088bd0d2f964c8d9e9f8c (diff)
downloadchessh-bot-0f5555b92915b175a685a24ade9276d170ae37f5.tar.gz
chessh-bot-0f5555b92915b175a685a24ade9276d170ae37f5.zip
move to docker compose, fuck vercel
remove other unnecesaary stuff
-rw-r--r--Dockerfile8
-rw-r--r--README.md2
-rw-r--r--api/index.ts3
-rw-r--r--docker-compose.yml12
-rw-r--r--jest.config.js6
-rw-r--r--package.json3
-rw-r--r--public/.gitkeep1
-rw-r--r--src/api/Chessh.ts (renamed from src/interfaces/Chessh.ts)0
-rw-r--r--src/api/index.ts2
-rw-r--r--src/interfaces/ErrorResponse.ts6
-rw-r--r--src/middlewares.ts4
-rw-r--r--test/api.test.ts25
-rw-r--r--test/app.test.ts25
-rw-r--r--tsconfig.json4
-rw-r--r--vercel.json3
15 files changed, 24 insertions, 80 deletions
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..d44f3a2
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,8 @@
+FROM node:alpine
+WORKDIR /usr/chessh_bot
+COPY package.json .
+RUN npm install\
+ && npm install typescript -g
+COPY . .
+RUN tsc
+CMD ["node", "./dist/src/index.js"]
diff --git a/README.md b/README.md
index bb3920d..4b1799f 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1 @@
# example chessh bot
-
-This is an example webhook handler for [chessh](https://github.com/usufslc/chessh). Deployed on vercel for free babe!
diff --git a/api/index.ts b/api/index.ts
deleted file mode 100644
index addcf99..0000000
--- a/api/index.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-import app from '../src/app';
-
-export default app;
diff --git a/docker-compose.yml b/docker-compose.yml
new file mode 100644
index 0000000..5d7d23b
--- /dev/null
+++ b/docker-compose.yml
@@ -0,0 +1,12 @@
+version: '3'
+
+services:
+ server:
+ container_name: chesshbot
+ restart: always
+ env_file: .env
+ build:
+ context: .
+ dockerfile: Dockerfile
+ ports:
+ - 4200:4200
diff --git a/jest.config.js b/jest.config.js
deleted file mode 100644
index 33721e1..0000000
--- a/jest.config.js
+++ /dev/null
@@ -1,6 +0,0 @@
-/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
-module.exports = {
- preset: 'ts-jest',
- testEnvironment: 'node',
- modulePathIgnorePatterns: ['<rootDir>/dist/'],
-}; \ No newline at end of file
diff --git a/package.json b/package.json
index af83f18..f99e1d7 100644
--- a/package.json
+++ b/package.json
@@ -7,8 +7,7 @@
"start": "ts-node src/index.ts",
"dev": "nodemon src/index.ts",
"build": "tsc",
- "lint": "eslint --fix src test",
- "test": "jest",
+ "lint": "eslint --fix src",
"vercel-build": "echo hello"
},
"keywords": [],
diff --git a/public/.gitkeep b/public/.gitkeep
deleted file mode 100644
index 8b13789..0000000
--- a/public/.gitkeep
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/src/interfaces/Chessh.ts b/src/api/Chessh.ts
index 898fccb..898fccb 100644
--- a/src/interfaces/Chessh.ts
+++ b/src/api/Chessh.ts
diff --git a/src/api/index.ts b/src/api/index.ts
index ae9b26a..39f5b40 100644
--- a/src/api/index.ts
+++ b/src/api/index.ts
@@ -3,7 +3,7 @@ import {
BotMoveRequest,
BotMoveAttempt,
BotMoveResponse,
-} from '../interfaces/Chessh';
+} from './Chessh';
import axios from 'axios';
import { aiMove } from 'js-chess-engine';
diff --git a/src/interfaces/ErrorResponse.ts b/src/interfaces/ErrorResponse.ts
deleted file mode 100644
index 1513e10..0000000
--- a/src/interfaces/ErrorResponse.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-import MessageResponse from './MessageResponse';
-
-export default interface ErrorResponse extends MessageResponse {
- stack?: string;
- message: string;
-}
diff --git a/src/middlewares.ts b/src/middlewares.ts
index 249ff67..dc98a6c 100644
--- a/src/middlewares.ts
+++ b/src/middlewares.ts
@@ -1,7 +1,5 @@
import { NextFunction, Request, Response } from 'express';
-import ErrorResponse from './interfaces/ErrorResponse';
-
export function notFound(req: Request, res: Response, next: NextFunction) {
res.status(404);
const error = new Error(`🔍 - Not Found - ${req.originalUrl}`);
@@ -9,7 +7,7 @@ export function notFound(req: Request, res: Response, next: NextFunction) {
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
-export function errorHandler(err: Error, req: Request, res: Response<ErrorResponse>, next: NextFunction) {
+export function errorHandler(err: Error, req: Request, res: Response<{message: string, stack?: string | any[]}>, next: NextFunction) {
const statusCode = res.statusCode !== 200 ? res.statusCode : 500;
res.status(statusCode);
res.json({
diff --git a/test/api.test.ts b/test/api.test.ts
deleted file mode 100644
index 2e94e6d..0000000
--- a/test/api.test.ts
+++ /dev/null
@@ -1,25 +0,0 @@
-import request from 'supertest';
-
-import app from '../src/app';
-
-describe('GET /api/v1', () => {
- it('responds with a json message', (done) => {
- request(app)
- .get('/api/v1')
- .set('Accept', 'application/json')
- .expect('Content-Type', /json/)
- .expect(200, {
- message: 'API - 👋🌎🌍🌏',
- }, done);
- });
-});
-
-describe('GET /api/v1/emojis', () => {
- it('responds with a json message', (done) => {
- request(app)
- .get('/api/v1/emojis')
- .set('Accept', 'application/json')
- .expect('Content-Type', /json/)
- .expect(200, ['😀', '😳', '🙄'], done);
- });
-});
diff --git a/test/app.test.ts b/test/app.test.ts
deleted file mode 100644
index c9f37c2..0000000
--- a/test/app.test.ts
+++ /dev/null
@@ -1,25 +0,0 @@
-import request from 'supertest';
-
-import app from '../src/app';
-
-describe('app', () => {
- it('responds with a not found message', (done) => {
- request(app)
- .get('/what-is-this-even')
- .set('Accept', 'application/json')
- .expect('Content-Type', /json/)
- .expect(404, done);
- });
-});
-
-describe('GET /', () => {
- it('responds with a json message', (done) => {
- request(app)
- .get('/')
- .set('Accept', 'application/json')
- .expect('Content-Type', /json/)
- .expect(200, {
- message: '🦄🌈✨👋🌎🌍🌏✨🌈🦄',
- }, done);
- });
-});
diff --git a/tsconfig.json b/tsconfig.json
index 17028e0..13f6405 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -12,9 +12,7 @@
},
"include": [
"./*.js",
- "js-chess-engine.d.ts",
"api/**/*.ts",
- "src/**/*.ts",
- "test/**/*.ts"
+ "src/**/*.ts"
]
}
diff --git a/vercel.json b/vercel.json
deleted file mode 100644
index 18da4e3..0000000
--- a/vercel.json
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "rewrites": [{ "source": "/(.*)", "destination": "/api" }]
-}