-
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.
Merge pull request #10 from bmstu-itstech/dev
release v1.0.0
- Loading branch information
Showing
169 changed files
with
12,591 additions
and
174 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,5 @@ | ||
.git* | ||
.results | ||
*Dockerfile* | ||
node_modules | ||
*.env* |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 @@ | ||
FROM node:alpine | ||
|
||
WORKDIR /app | ||
|
||
COPY package.json package-lock.json ./ | ||
RUN npm i | ||
|
||
COPY . ./ | ||
|
||
EXPOSE 3000 | ||
|
||
ENTRYPOINT ["npm", "run", "dev"] |
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,7 @@ | ||
services: | ||
client: | ||
build: | ||
context: . | ||
restart: unless-stopped | ||
ports: | ||
- "80:3000" |
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 |
---|---|---|
@@ -1,7 +1,28 @@ | ||
import type { NextConfig } from "next"; | ||
import type {NextConfig} from "next"; | ||
|
||
const nextConfig: NextConfig = { | ||
/* config options here */ | ||
images: { | ||
remotePatterns: [ | ||
{ | ||
protocol: 'http', | ||
hostname: 'localhost', | ||
port: '5000', | ||
pathname: '/**', | ||
}, | ||
{ | ||
protocol: 'https', | ||
hostname: 's3-alpha-sig.figma.com', | ||
port: '', | ||
pathname: '/**', | ||
}, | ||
{ | ||
protocol: 'https', | ||
hostname: 'via.placeholder.com', | ||
port: '', | ||
pathname: '/**', | ||
}, | ||
], | ||
} | ||
}; | ||
|
||
export default nextConfig; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,36 @@ | ||
import "express-async-errors"; | ||
import "dotenv/config"; | ||
import next from "next"; | ||
import express, { NextFunction, Request, Response } from "express"; | ||
import mongoose from "mongoose"; | ||
import cors from "cors"; | ||
import api from "./server/src/routers"; | ||
|
||
const app = express(); | ||
|
||
app.use(express.json()); | ||
app.use(express.urlencoded({ extended: false })); | ||
app.use(cors()); | ||
app.use("/api", api); | ||
|
||
const PORT = process.env.PORT || 8080; | ||
const DB_URI = process.env.DB_URI || "mongodb://localhost:27017"; | ||
const dev = process.env.NODE_ENV !== 'production'; | ||
|
||
app.use((err: Error, req: Request, res: Response, next: NextFunction) => { | ||
res.status(500).send({ message: err.message }); | ||
}); | ||
|
||
const frontend = next({ dev }); | ||
const handle = frontend.getRequestHandler(); | ||
frontend.prepare().then(() => { | ||
app.use("*", (req, res) => handle(req, res)); | ||
}); | ||
|
||
async function start() { | ||
await mongoose.connect(DB_URI); | ||
console.log("MongoDB connected."); | ||
app.listen(PORT, () => console.log("Server started")); | ||
}; | ||
|
||
start(); |
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,44 @@ | ||
import { Request, Response } from "express"; | ||
import { Achievement } from "../models"; | ||
import { isNumber } from "../validators/base"; | ||
import { sendError } from "../helpers"; | ||
import validators from "../validators"; | ||
|
||
async function getAchievements(req: Request, res: Response) { | ||
const offset = Number(req.query.offset); | ||
if (!isNumber(offset)) { | ||
return sendError(res, 400, "Неверное смещение"); | ||
}; | ||
const achievements = await Achievement.get(offset); | ||
res.status(200).json(achievements); | ||
}; | ||
|
||
async function createAchievement(req: Request, res: Response) { | ||
const rawAchievement = validators.achievement.validateRaw(req.body); | ||
const achievement = await Achievement.add(rawAchievement); | ||
res.status(200).json(achievement); | ||
}; | ||
|
||
async function editAchievement(req: Request, res: Response) { | ||
const rawAchievement = validators.achievement.validate(req.body); | ||
const achievement = await Achievement.update(rawAchievement); | ||
res.status(200).json(achievement); | ||
}; | ||
|
||
async function deleteAchievement(req: Request, res: Response) { | ||
await Achievement.remove(req.params.achievementId); | ||
res.status(200).json({ result: 1 }); | ||
}; | ||
|
||
async function getAchievementById(req: Request, res: Response) { | ||
const achievement = await Achievement.getById(req.params.achievementId); | ||
res.status(200).json(achievement); | ||
}; | ||
|
||
export { | ||
getAchievements, | ||
createAchievement, | ||
editAchievement, | ||
deleteAchievement, | ||
getAchievementById | ||
}; |
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,35 @@ | ||
import { Request, Response } from "express"; | ||
import { sendError } from "../helpers"; | ||
import { Doc } from "../models"; | ||
import validators from "../validators"; | ||
import { isString } from "../validators/base"; | ||
|
||
async function getDocs(req: Request, res: Response) { | ||
const ids = (req.query.ids as string).split(","); | ||
if (ids.length === 0) { | ||
return sendError(res, 400, "Передан пустой массив идентификаторов"); | ||
}; | ||
const docs = await Doc.getByIds(ids); | ||
res.status(200).json(docs); | ||
}; | ||
|
||
async function addDoc(req: Request, res: Response) { | ||
const rawDoc = validators.doc.validateRaw(req.body); | ||
const doc = await Doc.add(rawDoc); | ||
res.status(200).json(doc); | ||
}; | ||
|
||
async function removeDoc(req: Request, res: Response) { | ||
const { docId } = req.query; | ||
if (!isString(docId)) { | ||
return sendError(res, 400, "Неверный идентификатор документа"); | ||
}; | ||
await Doc.remove(docId); | ||
res.status(200).json({ result: 1 }); | ||
}; | ||
|
||
export { | ||
getDocs, | ||
addDoc, | ||
removeDoc | ||
}; |
Oops, something went wrong.