-
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.
- Loading branch information
Showing
6 changed files
with
59 additions
and
33 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 |
---|---|---|
@@ -1,4 +1,6 @@ | ||
node_modules/ | ||
build/ | ||
src/_tmp | ||
.env | ||
.DS_Store | ||
*.lmdb* | ||
|
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,10 +1,15 @@ | ||
FROM node:20.8.0-alpine | ||
|
||
FROM node:20.8.0-alpine as builder | ||
# possibly for future usage | ||
# RUN apt-get update -y | ||
# RUN apt-get install -y build-essential libcairo2-dev libpango1.0-dev libjpeg-dev libgif-dev librsvg2-dev | ||
WORKDIR /srv/www | ||
COPY . . | ||
RUN npm i | ||
RUN npm run build-prod | ||
|
||
FROM node:20.8.0-alpine | ||
WORKDIR /srv/www | ||
COPY --chown=node:node --from=builder /srv/www/build/ ./ | ||
RUN npm i --omit=dev | ||
USER node | ||
CMD ["npm", "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
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,46 @@ | ||
import { FastifyReply, FastifyRequest } from "fastify"; | ||
// import { open as openLmdb } from "lmdb"; | ||
// import * as config from "./config.js"; | ||
|
||
type RedirectRequest = FastifyRequest<{ | ||
Querystring: { where: string }; | ||
}>; | ||
// type StoreRequest = FastifyRequest<{ | ||
// Querystring: { fullpath: string }; | ||
// }>; | ||
|
||
// const lmdbHandler = openLmdb(config.READS_STORE_PATH, {}); | ||
|
||
// export async function storeReadCount( | ||
// request: StoreRequest, | ||
// serverReply: FastifyReply | ||
// ) { | ||
// if ( | ||
// !request.query.fullpath || | ||
// !request.query.fullpath.startsWith("/") || | ||
// request.query.fullpath.length < config.MIN_URL_FOR_READS_LENGTH | ||
// ) { | ||
// await serverReply.code(400).send("Not provided proper fullpath"); | ||
// } | ||
// const preparedPath = request.query.fullpath | ||
// .substring(0, config.MAX_URL_FOR_READS_LENGTH) | ||
// .trim(); | ||
// const previousCountRaw = parseInt(await lmdbHandler.get(preparedPath), 10); | ||
// const newCountValue = (isNaN(previousCountRaw) ? 0 : previousCountRaw) + 1; | ||
// await lmdbHandler.put(preparedPath, newCountValue); | ||
// serverReply.code(200).send({ count: newCountValue }); | ||
// await serverReply; | ||
// } | ||
|
||
export async function redirectSomewhere( | ||
request: RedirectRequest, | ||
serverReply: FastifyReply | ||
) { | ||
const preparedWhere = request.query.where.trim(); | ||
if (preparedWhere) { | ||
serverReply.code(301).redirect(preparedWhere); | ||
} else { | ||
serverReply.code(400).send("Not provided place where to redirect"); | ||
} | ||
await serverReply; | ||
} |
File renamed without changes.
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