fixed file saving in capes/skins, install dependencies early for faster rebuils
This commit is contained in:
parent
cccaf58ec3
commit
65530963d7
|
@ -2,8 +2,12 @@ FROM node:22-bullseye
|
|||
|
||||
WORKDIR /opt/mcserver
|
||||
|
||||
COPY . .
|
||||
COPY package.json package.json
|
||||
COPY package-lock.json package-lock.json
|
||||
|
||||
RUN npm i
|
||||
|
||||
COPY . .
|
||||
|
||||
EXPOSE 3000
|
||||
ENTRYPOINT ["node", "./src/index.js"]
|
|
@ -1,3 +1,5 @@
|
|||
|
||||
|
||||
import bcrypt from 'bcrypt';
|
||||
import jwt from 'jsonwebtoken';
|
||||
import path from 'path';
|
||||
|
@ -86,10 +88,12 @@ class UserController {
|
|||
if (image.bitmap.width != 64 || image.bitmap.height != 64) {
|
||||
return res.status(400).send('This does not look like a minecraft skin.');
|
||||
}
|
||||
|
||||
fs.renameSync(tempPath, targetPath, err => {
|
||||
if (err) return res.status(500).send("Ooops! Something went wrong! Please, report to the developer.");
|
||||
});
|
||||
try {
|
||||
await fs.promises.cp(tempPath, targetPath);
|
||||
await fs.promises.unlink(tempPath);
|
||||
} catch (err) {
|
||||
return res.status(500).send("Ooops! Something went wrong! Please, report to the developer.");
|
||||
}
|
||||
return res.status(200).send("Skin uploaded!");
|
||||
}
|
||||
|
||||
|
@ -108,9 +112,12 @@ class UserController {
|
|||
return res.status(400).send('This does not look like a minecraft cape.');
|
||||
}
|
||||
|
||||
fs.renameSync(tempPath, targetPath, err => {
|
||||
if (err) return res.status(500).send("Ooops! Something went wrong! Please, report to the developer.");
|
||||
});
|
||||
try {
|
||||
await fs.promises.cp(tempPath, targetPath);
|
||||
await fs.promises.unlink(tempPath);
|
||||
} catch (err) {
|
||||
return res.status(500).send("Ooops! Something went wrong! Please, report to the developer.");
|
||||
}
|
||||
|
||||
return res.status(200).send("Cape uploaded!");
|
||||
}
|
||||
|
|
|
@ -20,8 +20,9 @@ ApiRouter.post('/uploadCape', existance.userExist, auth.authenticate, auth.canHa
|
|||
|
||||
ApiRouter.get('/getUsername', existance.userExist, auth.authenticate, UserController.getUsername);
|
||||
ApiRouter.get('/getChatMessages/:offset/:limit', auth.authenticate, ApiController.getChatMessages);
|
||||
ApiRouter.get('/webSocketConnection', auth.authenticate, ApiController.getWebsocketConnection)
|
||||
ApiRouter.get('/webSocketConnection', auth.authenticate, ApiController.getWebsocketConnection);
|
||||
|
||||
ApiRouter.get('/skinsUrl', auth.authenticate, ApiController.getSkinsUrl);
|
||||
ApiRouter.get('/capesUrl', auth.authenticate, ApiController.getCapesUrl)
|
||||
ApiRouter.get('/capesUrl', auth.authenticate, ApiController.getCapesUrl);
|
||||
|
||||
export default ApiRouter;
|
Loading…
Reference in New Issue