Skip to content

Commit

Permalink
chore: initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
qin-guan committed Jul 13, 2023
0 parents commit 3dcc0f0
Show file tree
Hide file tree
Showing 207 changed files with 318,208 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
node_modules
*.log*
.nuxt
.nitro
.cache
.output
#.env # Not ignoring this file because it can contain build-related settings.
dist
.DS_Store
.eslintcache
.idea
55 changes: 55 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Since the ".env" file is gitignored, you can use the ".env.example" file to
# build a new ".env" file when you clone the repo. Keep this file up-to-date
# when you add new variables to `.env`.

# This file will be committed to version control, so make sure not to have any
# secrets in it. If you are cloning this repo, create a copy of this file named
# ".env" and populate it with your secrets.

# When adding additional environment variables, the schema in "/src/env.mjs"
# should be updated accordingly.

# Database settings
# =================
# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB.
# See the documentation for all the connection string options: https://pris.ly/d/connection-strings
NUXT_DATABASE_URL=postgres://root:root@localhost:26257/app

# Auth settings
# =============
# Expiry time for OTP in seconds. Default is 600 seconds (10 minutes).
NUXT_OTP_EXPIRY=600
# Secret to hash sessions. Can use https://1password.com/password-generator/ to generate a strong secret.
NUXT_SESSION_SECRET=random_session_secret_that_is_at_least_32_characters

# Mail settings
# =============
NUXT_POSTMAN_API_KEY=
# If using Sendgrid instead, the API token and "From" address must be set together.
NUXT_SENDGRID_API_KEY=
NUXT_SENDGRID_FROM_ADDRESS=

# Image upload settings
# =====================
# R2 API Keys for S3-compatible image upload
# If set to true, enables image upload
NUXT_PUBLIC_ENABLE_STORAGE=
NUXT_R2_ACCOUNT_ID=
NUXT_R2_BUCKET_NAME=
NUXT_R2_ACCESS_KEY_ID=
NUXT_R2_SECRET_ACCESS_KEY=
NUXT_R2_PUBLIC_HOSTNAME=

# SGID settings
# =============
# If set to true, enables SGID login
NUXT_PUBLIC_ENABLE_SGID=
NUXT_SGID_CLIENT_ID=
NUXT_SGID_CLIENT_SECRET=
NUXT_SGID_REDIRECT_URI=
NUXT_SGID_PRIVATE_KEY=

# Other settings
# ================
NUXT_PUBLIC_APP_NAME= # Uncomment to set application name

2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
docs/.vitepress/cache
docs/.vitepress/dist
6 changes: 6 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": [
"@antfu",
"@unocss"
]
}
36 changes: 36 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: ci

permissions:
contents: read

on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch: {}

jobs:
ci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: corepack enable
- uses: actions/setup-node@v3
with:
node-version: 18
cache: pnpm

- name: 📦 Install dependencies
run: pnpm install --frozen-lockfile

- name: 🚧 Set up project
run: pnpm nuxi prepare

- name: 📝 Lint
run: pnpm lint

- name: 💪 Type check
run: pnpm typecheck
16 changes: 16 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: deploy

on:
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: superfly/flyctl-actions/setup-flyctl@master
- run: flyctl deploy --remote-only -a starter-kit
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
56 changes: 56 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: build & push docker container

on:
push:
branches:
- main
tags:
- 'v*'
pull_request:
branches:
- main

jobs:
docker:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.metal.outputs.version }}
permissions:
contents: read
packages: write

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Docker meta
id: metal
uses: docker/metadata-action@v4
with:
images: |
ghcr.io/sagejs/starter-kit
- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to GitHub Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
platforms: linux/amd64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.metal.outputs.tags }}
labels: ${{ steps.metal.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
26 changes: 26 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: release

permissions:
contents: write

on:
push:
tags:
- 'v*'

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set node
uses: actions/setup-node@v3
with:
node-version: 18

- run: npx changelogithub
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
24 changes: 24 additions & 0 deletions .github/workflows/semantic-pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Semantic Pull Request

on:
pull_request_target:
types:
- opened
- edited
- synchronize

permissions: {}

jobs:
main:
permissions:
pull-requests: read # to analyze PRs (amannn/action-semantic-pull-request)
statuses: write # to mark status of analyzed PR (amannn/action-semantic-pull-request)

runs-on: ubuntu-latest
name: Semantic Pull Request
steps:
- name: Validate PR title
uses: amannn/action-semantic-pull-request@v5.2.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33 changes: 33 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Nuxt dev/build outputs
.output
.nuxt
.nitro
.cache
dist

# Node dependencies
node_modules

# Logs
logs
*.log

# Misc
.DS_Store
.fleet
.idea

# Local env files
.env
.env.*
!.env.example

# ESLint
.eslintcache

# VitePress
docs/.vitepress/dist
docs/.vitepress/cache

# Email
.react-email
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
shamefully-hoist=true
51 changes: 51 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
FROM docker.io/library/node:lts-alpine AS base

# Prepare work directory
WORKDIR /starter-kit

FROM base AS builder

# Prepare pnpm https://pnpm.io/installation#using-corepack
RUN corepack enable

# Prepare deps
RUN apk update
RUN apk add git --no-cache

# Prepare build deps ( ignore postinstall scripts for now )
COPY .npmrc ./
COPY package.json ./
COPY pnpm-lock.yaml ./

RUN pnpm i --frozen-lockfile --ignore-scripts

# Copy all source files
COPY . ./

# Run full install with every postinstall script ( This needs project file )
RUN pnpm i --frozen-lockfile

# Build
RUN pnpm build

FROM base AS runner

ARG UID=911
ARG GID=911

# Create a dedicated user and group
RUN set -eux; \
addgroup -g $GID starter-kit; \
adduser -u $UID -D -G starter-kit starter-kit;

USER starter-kit

ENV NODE_ENV=production

COPY --from=builder /starter-kit/.output ./.output

EXPOSE 3000/tcp

ENV PORT=3000

CMD ["node", ".output/server/index.mjs"]
49 changes: 49 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
Copyright (c) 2023 Qin Guan. All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Ngee Ann Polytechnic nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

MIT License

Copyright (c) 2023 Open Government Products

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Loading

0 comments on commit 3dcc0f0

Please sign in to comment.