Skip to content

Commit

Permalink
Merge pull request #10 from bmstu-itstech/dev
Browse files Browse the repository at this point in the history
release v1.0.0
  • Loading branch information
darleet authored Jan 9, 2025
2 parents bed8df1 + 0d34a41 commit b8ebbd0
Show file tree
Hide file tree
Showing 169 changed files with 12,591 additions and 174 deletions.
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.git*
.results
*Dockerfile*
node_modules
*.env*
6 changes: 6 additions & 0 deletions .idea/git_toolbox_blame.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions Dockerfile
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"]
7 changes: 7 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
services:
client:
build:
context: .
restart: unless-stopped
ports:
- "80:3000"
25 changes: 23 additions & 2 deletions next.config.ts
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;
73 changes: 73 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,20 @@
"build-storybook": "storybook build"
},
"dependencies": {
"@types/cors": "^2.8.17",
"@types/express": "^5.0.0",
"ajv": "^8.17.1",
"bcryptjs": "^2.4.3",
"cors": "^2.8.5",
"dotenv": "^16.4.7",
"embla-carousel-react": "^8.5.1",
"express": "^4.21.2",
"express-async-errors": "^3.1.1",
"express-validator": "^7.2.1",
"framer-motion": "^11.14.3",
"jsonwebtoken": "^9.0.2",
"mobx": "^6.13.5",
"mongoose": "^8.9.3",
"next": "15.0.4",
"react": "^19.0.0",
"react-dom": "^19.0.0"
Expand All @@ -25,9 +38,12 @@
"@storybook/nextjs": "^8.4.7",
"@storybook/react": "^8.4.7",
"@storybook/test": "^8.4.7",
"@types/bcryptjs": "^2.4.6",
"@types/jsonwebtoken": "^9.0.7",
"@types/node": "^20",
"@types/react": "^19",
"@types/react-dom": "^19",
"@types/react-gallery-carousel": "^0.2.6",
"eslint": "^8",
"eslint-config-next": "15.0.4",
"eslint-plugin-storybook": "^0.11.1",
Expand Down
Binary file added public/achievement-example.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/backgrounds/1st.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/backgrounds/2nd.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/backgrounds/3rd.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/backgrounds/4th.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/backgrounds/transition.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions public/close_icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion public/file.svg

This file was deleted.

1 change: 0 additions & 1 deletion public/globe.svg

This file was deleted.

7 changes: 7 additions & 0 deletions public/menu_canvas.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions public/menu_icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion public/next.svg

This file was deleted.

1 change: 0 additions & 1 deletion public/vercel.svg

This file was deleted.

1 change: 0 additions & 1 deletion public/window.svg

This file was deleted.

36 changes: 36 additions & 0 deletions server.ts
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();
44 changes: 44 additions & 0 deletions server/src/controllers/achievements.controller.ts
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
};
35 changes: 35 additions & 0 deletions server/src/controllers/docs.controller.ts
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
};
Loading

0 comments on commit b8ebbd0

Please sign in to comment.