Browse Source

Merge branch 'route' of ssh://git.xieyaxin.top:8892/topuser/koa3-demo into route

re
谢亚昕 3 months ago
parent
commit
a639953adb
  1. 6
      Dockerfile
  2. BIN
      database/development.sqlite3-shm
  3. BIN
      database/development.sqlite3-wal
  4. 8
      src/middlewares/install.js
  5. 3
      src/views/page/profile/index.pug

6
Dockerfile

@ -10,14 +10,14 @@ RUN apk add --no-cache python3 make g++ gcc dos2unix
COPY --chown=bun:bun ./package.json ./package.json
COPY --chown=bun:bun ./bun.lockb ./bun.lockb
COPY --chown=bun:bun ./knexfile.mjs ./knexfile.mjs
COPY --chown=bun:bun ./.env.production ./.env.production
COPY --chown=bun:bun ./jsconfig.json ./jsconfig.json
COPY --chown=bun:bun ./src ./src
COPY --chown=bun:bun ./public ./public
COPY --chown=bun:bun ./entrypoint.sh ./entrypoint.sh
# 安装生产依赖和修复 entrypoint.sh
RUN bun install --frozen-lockfile --production --registry https://registry.npmjs.org && \
# RUN bun install --frozen-lockfile --production --registry https://registry.npmjs.org && \
RUN bun install --frozen-lockfile --production && \
# 修复 entrypoint.sh 的换行符
dos2unix ./entrypoint.sh && \
chmod +x ./entrypoint.sh
@ -46,3 +46,5 @@ HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
# 设置入口点
ENTRYPOINT ["./entrypoint.sh"]
# docker build -t koa3-demo .

BIN
database/development.sqlite3-shm

Binary file not shown.

BIN
database/development.sqlite3-wal

Binary file not shown.

8
src/middlewares/install.js

@ -8,8 +8,8 @@ import { Auth } from "./Auth"
import bodyParser from "koa-bodyparser"
import Views from "./Views"
import Session from "./Session"
import etag from "@koa/etag"
import conditional from "koa-conditional-get"
import etag from "@koa/etag"
import conditional from "koa-conditional-get"
import { autoRegisterControllers } from "@/utils/ForRegister.js"
const __dirname = path.dirname(fileURLToPath(import.meta.url))
@ -21,7 +21,7 @@ export default app => {
// 响应时间
app.use(ResponseTime)
// session设置
app.use(Session(app));
app.use(Session(app))
// 权限设置
app.use(
Auth({
@ -44,7 +44,7 @@ export default app => {
extension: "pug",
options: {
basedir: resolve(__dirname, "../views"),
}
},
})
)
// 请求体解析

3
src/views/page/profile/index.pug

@ -459,6 +459,9 @@ block pageHead
}
block pageContent
form(action="/profile/upload-avatar" method="post" enctype="multipart/form-data")
input(type="file", name="avatar", accept="image/*" onchange="document.getElementById('upload-btn').click()")
button#upload-btn(type="submit") 上传头像
.profile-container
.profile-sidebar
.profile-avatar

Loading…
Cancel
Save