Merge branch 'ts-analytics' of https://github.com/linux-odyssey/linux-odyssey into ts-analytics

This commit is contained in:
chreamy committed 2024-03-05 01:27:10 -06:00
commit 94ae2d7df4
34 files changed
+291 -96

No files matched your search

+2
View File
@@ -0,0 +1,2 @@
ADMIN_USERNAME=alex
ADMIN_PASSWORD=Alex1234
+2 -3
View File
@@ -1,11 +1,10 @@
FROM node:20-alpine as build
WORKDIR /app
COPY ./package.json yarn.lock ./
COPY ./package.json yarn.lock tsconfig.json ./
COPY packages/analytics/package.json ./packages/analytics/package.json
COPY packages/models/package.json ./packages/models/package.json
RUN yarn set version berry
RUN yarn install
RUN yarn install --frozen-lockfile
ENV HOST=0.0.0.0
ENV PORT=3001
EXPOSE 3001
+2 -2
View File
@@ -1,6 +1,6 @@
{
"watch": ["src"],
"watch": ["src", "views"],
"ext": "ts,handlebars,js",
"ignore": ["src/**/*.spec.ts"],
"exec": "node --loader ts-node/esm src/index.ts"
"exec": "node --loader ts-node/esm src/index.js"
}
+5
View File
@@ -13,14 +13,19 @@
},
"dependencies": {
"@linux-odyssey/models": "*",
"dotenv": "^16.4.5",
"express": "^4.18.2",
"express-basic-auth": "^1.2.1",
"express-handlebars": "^7.1.2",
"mongoose": "^8.0.3"
},
"devDependencies": {
"@swc/core": "^1.4.2",
"@swc/helpers": "^0.5.6",
"@types/express": "^4.17.21",
"@types/node": "^20.11.20",
"nodemon": "^3.1.0",
"regenerator-runtime": "^0.14.1",
"ts-node": "^10.9.2",
"typescript": "^5.3.3"
}
+10 -4
View File
@@ -1,3 +1,9 @@
import dotenv from 'dotenv'
if (process.env.NODE_ENV !== 'production') {
dotenv.config({ path: '.env.dev' })
}
function getOrFailed(key: string): string {
if (!process.env[key]) {
throw new Error(`Missing required environment variable: ${key}`)
@@ -16,13 +22,13 @@ interface Config {
const config: Config = {
host: process.env.HOST || 'localhost',
port: process.env.PORT ? parseInt(process.env.PORT) : 3001,
port: process.env.PORT ? parseInt(process.env.PORT, 10) : 3001,
db: process.env.MONGO_URL || 'mongodb://localhost:27017/odyssey-test',
username: 'a' || getOrFailed('ADMIN_USERNAME'),
password: 'a' || getOrFailed('ADMIN_PASSWORD'),
username: getOrFailed('ADMIN_USERNAME'),
password: getOrFailed('ADMIN_PASSWORD'),
baseUrl:
process.env.BASE_URL ||
`http://${process.env.HOST || 'localhost'}:${process.env.PORT ? parseInt(process.env.PORT) : 3001}`,
`http://${process.env.HOST || 'localhost'}:${process.env.PORT ? parseInt(process.env.PORT, 10) : 3001}`,
}
export default config
+1 -1
View File
@@ -1,4 +1,4 @@
import { questList } from '../models/quests.ts'
import { questList } from '../models/quests.js'
// eslint-disable-next-line import/prefer-default-export
export async function questListController(req: any, res: any) {
const quests = await questList()
@@ -1,5 +1,10 @@
<<<<<<< HEAD
import Pagination from '../models/pagination.ts'
import { userList, userDetail, idToUser } from '../models/users.js'
=======
import Pagination from '../models/pagination.js'
import { userList } from '../models/users.js'
>>>>>>> bb4a11b20c8fdad8459ac3b7a0fdb8d9d9221e31
export async function userListController(req: any, res: any) {
const { nextKey, order } = req.query
@@ -20,6 +25,7 @@ export async function userListController(req: any, res: any) {
res.status(500).send('Error fetching user data')
}
}
<<<<<<< HEAD
export async function userDetailController(req: any, res: any) {
const { id } = req.params
const sessions = await userDetail(id)
@@ -31,3 +37,5 @@ export async function userDetailController(req: any, res: any) {
res.status(500).send('Error fetching user data')
}
}
=======
>>>>>>> bb4a11b20c8fdad8459ac3b7a0fdb8d9d9221e31
+4 -2
View File
@@ -1,7 +1,6 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"allowJs": true,
"rootDir": "src",
"outDir": "./dist",
"esModuleInterop": true,
@@ -9,5 +8,8 @@
"allowImportingTsExtensions": true
},
"include": ["src"],
"exclude": ["node_modules", "dist"]
"exclude": ["node_modules", "dist"],
"ts-node": {
"swc": true
}
}