mirror of
https://github.com/stonith404/pingvin-share.git
synced 2025-01-15 01:14:27 -05:00
Merge branch 'main' into development
This commit is contained in:
commit
5a9eb58096
11 changed files with 25 additions and 27 deletions
|
@ -13,10 +13,6 @@ COPY ./backend .
|
|||
RUN npx prisma generate
|
||||
RUN npm run build
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
FROM node:18 AS runner
|
||||
WORKDIR /opt/app/frontend
|
||||
ENV NODE_ENV=production
|
||||
|
|
13
README.md
13
README.md
|
@ -21,26 +21,25 @@ Demo: https://pingvin-share.dev.eliasschneider.com
|
|||
|
||||
1. Download the `docker-compose.yml` and `.env.example` file.
|
||||
2. Rename the `.env.example` file to `.env` and change the environment variables so that they fit to your environment. If you need help with the environment variables take a look [here](#environment-variables)
|
||||
3. Create a folder in the same folder as your `docker-compose.yml` file named `data` and create a file named `pingvin-share.db` in it.
|
||||
4. Run `docker-compose up -d`
|
||||
3. Run `docker-compose up -d`
|
||||
|
||||
The website is now listening available on `http://localhost:8080`, have fun with Pingvin Share 🐧!
|
||||
The website is now listening available on `http://localhost:3000`, have fun with Pingvin Share 🐧!
|
||||
|
||||
### Environment variables
|
||||
|
||||
| Variable | Description | Possible values |
|
||||
| -------------------- | ------------------------------------------------------------------------------------------- | --------------- |
|
||||
| `APP_URL` | On which URL Pingvin Share is available. E.g http://localhost or https://pingvin-share.com. | URL |
|
||||
| `SHOW_HOME_PAGE` | Wether the Pingvin Share home page should be shown. | true/false |
|
||||
| `ALLOW_REGISTRATION` | Wether a new user can create a new account. | true/false |
|
||||
| `SHOW_HOME_PAGE` | Whether the Pingvin Share home page should be shown. | true/false |
|
||||
| `ALLOW_REGISTRATION` | Whether a new user can create a new account. | true/false |
|
||||
| `MAX_FILE_SIZE` | Maximum allowed size per file in bytes. | Number |
|
||||
| `JWT_SECRET` | Random string to sign the JWT's. | Random string |
|
||||
| `JWT_SECRET` | Long random string to sign the JWT's. | Random string |
|
||||
|
||||
### Upgrade to a new version
|
||||
|
||||
Just updated the docker container by running `docker-compose pull && docker-compose up -d`
|
||||
|
||||
>Note: If you installed Pingvin Share before it used Sqlite, you unfortunately have to set up the project from scratch again, sorry for that.
|
||||
> Note: If you installed Pingvin Share before it used Sqlite, you unfortunately have to set up the project from scratch again, sorry for that.
|
||||
|
||||
## 🖤 Contribute
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ generator client {
|
|||
|
||||
datasource db {
|
||||
provider = "sqlite"
|
||||
url = "file:./pingvin-share.db"
|
||||
url = "file:../data/pingvin-share.db"
|
||||
}
|
||||
|
||||
model User {
|
||||
|
|
|
@ -21,7 +21,7 @@ export class AuthController {
|
|||
|
||||
@Post("signUp")
|
||||
signUp(@Body() dto: AuthRegisterDTO) {
|
||||
if (!this.config.get("ALLOW_REGISTRATION"))
|
||||
if (this.config.get("ALLOW_REGISTRATION") == "false")
|
||||
throw new ForbiddenException("Registration is not allowed");
|
||||
return this.authService.signUp(dto);
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ export class FileController {
|
|||
@UseGuards(JwtGuard, ShareOwnerGuard)
|
||||
@UseInterceptors(
|
||||
FileInterceptor("file", {
|
||||
dest: "./uploads/_temp/",
|
||||
dest: "./data/uploads/_temp/",
|
||||
})
|
||||
)
|
||||
async create(
|
||||
|
|
|
@ -8,7 +8,6 @@ import { JwtService } from "@nestjs/jwt";
|
|||
import { randomUUID } from "crypto";
|
||||
import * as fs from "fs";
|
||||
import * as mime from "mime-types";
|
||||
import { join } from "path";
|
||||
import { PrismaService } from "src/prisma/prisma.service";
|
||||
|
||||
@Injectable()
|
||||
|
@ -29,10 +28,12 @@ export class FileService {
|
|||
|
||||
const fileId = randomUUID();
|
||||
|
||||
await fs.promises.mkdir(`./uploads/shares/${shareId}`, { recursive: true });
|
||||
await fs.promises.mkdir(`./data/uploads/shares/${shareId}`, {
|
||||
recursive: true,
|
||||
});
|
||||
fs.promises.rename(
|
||||
`./uploads/_temp/${file.filename}`,
|
||||
`./uploads/shares/${shareId}/${fileId}`
|
||||
`./data/uploads/_temp/${file.filename}`,
|
||||
`./data/uploads/shares/${shareId}/${fileId}`
|
||||
);
|
||||
|
||||
return await this.prisma.file.create({
|
||||
|
@ -53,7 +54,7 @@ export class FileService {
|
|||
if (!fileMetaData) throw new NotFoundException("File not found");
|
||||
|
||||
const file = fs.createReadStream(
|
||||
join(process.cwd(), `uploads/shares/${shareId}/${fileId}`)
|
||||
`./data/uploads/shares/${shareId}/${fileId}`
|
||||
);
|
||||
|
||||
return {
|
||||
|
@ -67,14 +68,14 @@ export class FileService {
|
|||
}
|
||||
|
||||
async deleteAllFiles(shareId: string) {
|
||||
await fs.promises.rm(`./uploads/shares/${shareId}`, {
|
||||
await fs.promises.rm(`./data/uploads/shares/${shareId}`, {
|
||||
recursive: true,
|
||||
force: true,
|
||||
});
|
||||
}
|
||||
|
||||
getZip(shareId: string) {
|
||||
return fs.createReadStream(`./uploads/shares/${shareId}/archive.zip`);
|
||||
return fs.createReadStream(`./data/uploads/shares/${shareId}/archive.zip`);
|
||||
}
|
||||
|
||||
getFileDownloadUrl(shareId: string, fileId: string) {
|
||||
|
|
|
@ -7,7 +7,7 @@ async function bootstrap() {
|
|||
app.useGlobalPipes(new ValidationPipe());
|
||||
app.useGlobalInterceptors(new ClassSerializerInterceptor(app.get(Reflector)));
|
||||
|
||||
await fs.promises.mkdir("./uploads/_temp", { recursive: true });
|
||||
await fs.promises.mkdir("./data/uploads/_temp", { recursive: true });
|
||||
|
||||
app.setGlobalPrefix("api");
|
||||
await app.listen(8080);
|
||||
|
|
|
@ -8,7 +8,7 @@ export class PrismaService extends PrismaClient {
|
|||
super({
|
||||
datasources: {
|
||||
db: {
|
||||
url: "file:./pingvin-share.db",
|
||||
url: "file:../data/pingvin-share.db",
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
|
@ -57,7 +57,7 @@ export class ShareService {
|
|||
}
|
||||
|
||||
async createZip(shareId: string) {
|
||||
const path = `./uploads/shares/${shareId}`;
|
||||
const path = `./data/uploads/shares/${shareId}`;
|
||||
|
||||
const files = await this.prisma.file.findMany({ where: { shareId } });
|
||||
const archive = archiver("zip", {
|
||||
|
|
|
@ -12,5 +12,4 @@ services:
|
|||
- MAX_FILE_SIZE=${MAX_FILE_SIZE}
|
||||
- JWT_SECRET=${JWT_SECRET}
|
||||
volumes:
|
||||
- "${PWD}/data/uploads:/opt/app/backend/uploads"
|
||||
- "${PWD}/data/pingvin-share.db:/opt/app/backend/prisma/pingvin-share.db"
|
||||
- "${PWD}/data:/opt/app/backend/data"
|
||||
|
|
|
@ -1,14 +1,17 @@
|
|||
import getConfig from "next/config";
|
||||
import { useRouter } from "next/router";
|
||||
import AuthForm from "../../components/auth/AuthForm";
|
||||
import Meta from "../../components/Meta";
|
||||
import useUser from "../../hooks/user.hook";
|
||||
|
||||
const { publicRuntimeConfig } = getConfig();
|
||||
|
||||
const SignUp = () => {
|
||||
const user = useUser();
|
||||
const router = useRouter();
|
||||
if (user) {
|
||||
router.replace("/");
|
||||
} else if (process.env.NEXT_PUBLIC_DISABLE_REGISTRATION) {
|
||||
} else if (publicRuntimeConfig.ALLOW_REGISTRATION == "false") {
|
||||
router.replace("/auth/signIn");
|
||||
} else {
|
||||
return (
|
||||
|
|
Loading…
Add table
Reference in a new issue