Initial commit

This commit is contained in:
Andrew 2024-02-02 14:36:51 +03:00
commit ab35775e94
27 changed files with 16432 additions and 0 deletions

16
.editorconfig Normal file
View File

@ -0,0 +1,16 @@
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[{package.json,*.yml}]
indent_style = space
indent_size = 2
[*.md]
trim_trailing_whitespace = false

22
.env.example Normal file
View File

@ -0,0 +1,22 @@
HOST=0.0.0.0
PORT=1337
APP_URL=https://api.enderman.ch/cms
APP_ADMIN_PREFIX=/panel
APP_KEYS="toBeModified1,toBeModified2"
API_TOKEN_SALT=tobemodified
JWT_SECRET=tobemodified
ADMIN_JWT_SECRET=tobemodified
TRANSFER_TOKEN_SALT=tobemodified
# Database
DATABASE_CLIENT=postgres
DATABASE_HOST=127.0.0.1
DATABASE_PORT=5432
DATABASE_NAME=cms
DATABASE_USERNAME=postgres
DATABASE_PASSWORD=password
DATABASE_SSL=false
# Build
APP_DIRECTORY=/opt
NODE_ENV=development

114
.gitignore vendored Normal file
View File

@ -0,0 +1,114 @@
############################
# OS X
############################
.DS_Store
.AppleDouble
.LSOverride
Icon
.Spotlight-V100
.Trashes
._*
############################
# Linux
############################
*~
############################
# Windows
############################
Thumbs.db
ehthumbs.db
Desktop.ini
$RECYCLE.BIN/
*.cab
*.msi
*.msm
*.msp
############################
# Packages
############################
*.7z
*.csv
*.dat
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
*.zip
*.com
*.class
*.dll
*.exe
*.o
*.seed
*.so
*.swo
*.swp
*.swn
*.swm
*.out
*.pid
############################
# Logs and databases
############################
.tmp
*.log
*.sql
*.sqlite
*.sqlite3
############################
# Misc.
############################
*#
ssl
.idea
nbproject
public/uploads/*
!public/uploads/.gitkeep
############################
# Node.js
############################
lib-cov
lcov.info
pids
logs
results
node_modules
.node_history
############################
# Tests
############################
coverage
############################
# Strapi
############################
.env
license.txt
exports
.strapi
dist
build
.strapi-updater.json

57
README.md Normal file
View File

@ -0,0 +1,57 @@
# 🚀 Getting started with Strapi
Strapi comes with a full featured [Command Line Interface](https://docs.strapi.io/dev-docs/cli) (CLI) which lets you scaffold and manage your project in seconds.
### `develop`
Start your Strapi application with autoReload enabled. [Learn more](https://docs.strapi.io/dev-docs/cli#strapi-develop)
```
npm run develop
# or
yarn develop
```
### `start`
Start your Strapi application with autoReload disabled. [Learn more](https://docs.strapi.io/dev-docs/cli#strapi-start)
```
npm run start
# or
yarn start
```
### `build`
Build your admin panel. [Learn more](https://docs.strapi.io/dev-docs/cli#strapi-build)
```
npm run build
# or
yarn build
```
## ⚙️ Deployment
Strapi gives you many possible deployment options for your project including [Strapi Cloud](https://cloud.strapi.io). Browse the [deployment section of the documentation](https://docs.strapi.io/dev-docs/deployment) to find the best solution for your use case.
## 📚 Learn more
- [Resource center](https://strapi.io/resource-center) - Strapi resource center.
- [Strapi documentation](https://docs.strapi.io) - Official Strapi documentation.
- [Strapi tutorials](https://strapi.io/tutorials) - List of tutorials made by the core team and the community.
- [Strapi blog](https://strapi.io/blog) - Official Strapi blog containing articles made by the Strapi team and the community.
- [Changelog](https://strapi.io/changelog) - Find out about the Strapi product updates, new features and general improvements.
Feel free to check out the [Strapi GitHub repository](https://github.com/strapi/strapi). Your feedback and contributions are welcome!
## ✨ Community
- [Discord](https://discord.strapi.io) - Come chat with the Strapi community including the core team.
- [Forum](https://forum.strapi.io/) - Place to discuss, ask questions and find answers, show your Strapi project and get feedback or just talk with other Community members.
- [Awesome Strapi](https://github.com/strapi/awesome-strapi) - A curated list of awesome things related to Strapi.
---
<sub>🤫 Psst! [Strapi is hiring](https://strapi.io/careers).</sub>

51
docker-compose.yml Normal file
View File

@ -0,0 +1,51 @@
version: '3'
services:
db:
image: postgres:alpine
container_name: "cms-postgres"
hostname: "postgres"
networks:
- cms
volumes:
- ./postgres:/var/lib/postgresql/data
environment:
- POSTGRES_INITDB_ARGS=--auth-local=scram-sha-256 --auth-host=scram-sha-256 --locale=en_US.UTF-8
- POSTGRES_DB=${DATABASE_NAME:-cms}
- POSTGRES_USER=${DATABASE_USERNAME:-postgres}
- POSTGRES_PASSWORD=${DATABASE_PASSWORD:-password}
healthcheck:
test: ["CMD", "pg_isready", "-q", "-U", "${DATABASE_USERNAME:-postgres}", "-d", "${DATABASE_NAME:-cms}"]
interval: 1s
timeout: 5s
retries: 10
restart: unless-stopped
cms:
build:
context: ./strapi
dockerfile: Dockerfile
args:
- APP_DIRECTORY=${APP_DIRECTORY}
- NODE_ENV=${NODE_ENV}
image: endermanch/strapi
container_name: "cms-strapi"
hostname: "strapi"
networks:
- cms
volumes:
- ./data/package.json:${APP_DIRECTORY:-/opt/strapi}/package.json
- ./data/src:${APP_DIRECTORY:-/opt/strapi}/src
- ./data/config:${APP_DIRECTORY:-/opt/strapi}/config
- ./data/public:${APP_DIRECTORY:-/opt/strapi}/public
ports:
- '127.0.0.1:3684:8000'
env_file:
- .env
depends_on:
- db
restart: unless-stopped
networks:
cms:
driver: bridge

2
strapi/.dockerignore Normal file
View File

@ -0,0 +1,2 @@
node_modules/
dist/build/

60
strapi/Dockerfile Normal file
View File

@ -0,0 +1,60 @@
FROM node:18-alpine as build
ARG APP_DIRECTORY
ARG NODE_ENV
# Set working directory
WORKDIR ${APP_DIRECTORY}
# Upgrade & install system dependencies
RUN apk update
RUN apk add --no-cache \
build-base gcc autoconf automake zlib-dev libpng-dev vips-dev git \
> /dev/null 2>&1
# Copy dependency files
COPY package.json package-lock.json ./
# Install production dependencies
RUN npm config set registry https://registry.npmjs.org/
RUN npm install -g node-gyp
RUN npm ci --omit=dev --loglevel verbose
# Add node_modules/.bin to PATH
ENV PATH ${APP_DIRECTORY}/node_modules/.bin:$PATH
# Copy source files and build
WORKDIR ${APP_DIRECTORY}/app
COPY . .
RUN npm run build
FROM node:18-alpine as production
ARG APP_DIRECTORY
ARG NODE_ENV
ENV TIMEZONE "UTC"
# Set local timezone
RUN ln -snf /usr/share/zoneinfo/${TIMEZONE} /etc/localtime && echo ${TIMEZONE} > /etc/timezone
# Upgrade & install image processing dependency
RUN apk upgrade --no-cache && \
apk add --no-cache vips-dev
# Copy node_modules over to the parent directory
WORKDIR ${APP_DIRECTORY}
COPY --from=build ${APP_DIRECTORY}/node_modules ./node_modules
# Copy app files
WORKDIR ${APP_DIRECTORY}/app
COPY --from=build ${APP_DIRECTORY}/app .
# Add node_modules/.bin to PATH
ENV PATH ${APP_DIRECTORY}/node_modules/.bin:$PATH
# Set user and group rights
RUN chown -R node:node ${APP_DIRECTORY}
# Run as node
USER node
CMD ["npm", "run", "develop"]

18
strapi/config/admin.ts Normal file
View File

@ -0,0 +1,18 @@
export default ({ env }) => ({
auth: {
secret: env('ADMIN_JWT_SECRET'),
},
apiToken: {
salt: env('API_TOKEN_SALT'),
},
transfer: {
token: {
salt: env('TRANSFER_TOKEN_SALT'),
},
},
flags: {
nps: env.bool('FLAG_NPS', true),
promoteEE: env.bool('FLAG_PROMOTE_EE', true),
},
url: env('APP_ADMIN_PREFIX', '/dashboard'),
});

8
strapi/config/api.ts Normal file
View File

@ -0,0 +1,8 @@
export default {
rest: {
prefix: '/data',
defaultLimit: 25,
maxLimit: 100,
withCount: true,
},
};

93
strapi/config/database.ts Normal file
View File

@ -0,0 +1,93 @@
import path from 'path';
export default ({ env }) => {
const client = env('DATABASE_CLIENT', 'sqlite');
const connections = {
mysql: {
connection: {
connectionString: env('DATABASE_URL'),
host: env('DATABASE_HOST', 'localhost'),
port: env.int('DATABASE_PORT', 3306),
database: env('DATABASE_NAME', 'strapi'),
user: env('DATABASE_USERNAME', 'strapi'),
password: env('DATABASE_PASSWORD', 'strapi'),
ssl: env.bool('DATABASE_SSL', false) && {
key: env('DATABASE_SSL_KEY', undefined),
cert: env('DATABASE_SSL_CERT', undefined),
ca: env('DATABASE_SSL_CA', undefined),
capath: env('DATABASE_SSL_CAPATH', undefined),
cipher: env('DATABASE_SSL_CIPHER', undefined),
rejectUnauthorized: env.bool(
'DATABASE_SSL_REJECT_UNAUTHORIZED',
true
),
},
},
pool: { min: env.int('DATABASE_POOL_MIN', 2), max: env.int('DATABASE_POOL_MAX', 10) },
},
mysql2: {
connection: {
host: env('DATABASE_HOST', 'localhost'),
port: env.int('DATABASE_PORT', 3306),
database: env('DATABASE_NAME', 'strapi'),
user: env('DATABASE_USERNAME', 'strapi'),
password: env('DATABASE_PASSWORD', 'strapi'),
ssl: env.bool('DATABASE_SSL', false) && {
key: env('DATABASE_SSL_KEY', undefined),
cert: env('DATABASE_SSL_CERT', undefined),
ca: env('DATABASE_SSL_CA', undefined),
capath: env('DATABASE_SSL_CAPATH', undefined),
cipher: env('DATABASE_SSL_CIPHER', undefined),
rejectUnauthorized: env.bool(
'DATABASE_SSL_REJECT_UNAUTHORIZED',
true
),
},
},
pool: { min: env.int('DATABASE_POOL_MIN', 2), max: env.int('DATABASE_POOL_MAX', 10) },
},
postgres: {
connection: {
connectionString: env('DATABASE_URL'),
host: env('DATABASE_HOST', 'localhost'),
port: env.int('DATABASE_PORT', 5432),
database: env('DATABASE_NAME', 'strapi'),
user: env('DATABASE_USERNAME', 'strapi'),
password: env('DATABASE_PASSWORD', 'strapi'),
ssl: env.bool('DATABASE_SSL', false) && {
key: env('DATABASE_SSL_KEY', undefined),
cert: env('DATABASE_SSL_CERT', undefined),
ca: env('DATABASE_SSL_CA', undefined),
capath: env('DATABASE_SSL_CAPATH', undefined),
cipher: env('DATABASE_SSL_CIPHER', undefined),
rejectUnauthorized: env.bool(
'DATABASE_SSL_REJECT_UNAUTHORIZED',
true
),
},
schema: env('DATABASE_SCHEMA', 'public'),
},
pool: { min: env.int('DATABASE_POOL_MIN', 2), max: env.int('DATABASE_POOL_MAX', 10) },
},
sqlite: {
connection: {
filename: path.join(
__dirname,
'..',
'..',
env('DATABASE_FILENAME', '.tmp/data.db')
),
},
useNullAsDefault: true,
},
};
return {
connection: {
client,
...connections[client],
acquireConnectionTimeout: env.int('DATABASE_CONNECTION_TIMEOUT', 60000),
},
};
};

View File

@ -0,0 +1,13 @@
export default [
'strapi::logger',
'strapi::errors',
'strapi::security',
'strapi::cors',
'strapi::poweredBy',
'strapi::query',
'strapi::body',
'strapi::session',
'strapi::favicon',
'strapi::public',
{ resolve: './src/middlewares/redirect' }
];

1
strapi/config/plugins.ts Normal file
View File

@ -0,0 +1 @@
export default () => ({});

11
strapi/config/server.ts Normal file
View File

@ -0,0 +1,11 @@
export default ({ env }) => ({
host: env('HOST', '0.0.0.0'),
port: env.int('PORT', 1337),
app: {
keys: env.array('APP_KEYS'),
},
webhooks: {
populateRelations: env.bool('WEBHOOKS_POPULATE_RELATIONS', false),
},
url: env('APP_URL', 'https://api.enderman.ch/cms'),
});

View File

BIN
strapi/favicon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 497 B

15820
strapi/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

35
strapi/package.json Normal file
View File

@ -0,0 +1,35 @@
{
"name": "cms",
"private": true,
"version": "0.1.0",
"description": "A Strapi application",
"scripts": {
"develop": "strapi develop",
"start": "strapi start",
"build": "strapi build",
"strapi": "strapi"
},
"devDependencies": {},
"dependencies": {
"@strapi/strapi": "4.19.1",
"@strapi/plugin-users-permissions": "4.19.1",
"@strapi/plugin-i18n": "4.19.1",
"@strapi/plugin-cloud": "4.19.1",
"pg": "8.8.0",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"react-router-dom": "5.3.4",
"styled-components": "5.3.3"
},
"author": {
"name": "A Strapi developer"
},
"strapi": {
"uuid": "46664143-0881-4173-b3bf-0cc5ed6810d6"
},
"engines": {
"node": ">=18.0.0 <=20.x.x",
"npm": ">=6.0.0"
},
"license": "MIT"
}

3
strapi/public/robots.txt Normal file
View File

@ -0,0 +1,3 @@
# To prevent search engines from seeing the site altogether, uncomment the next two lines:
# User-Agent: *
# Disallow: /

View File

View File

@ -0,0 +1,35 @@
export default {
config: {
locales: [
// 'ar',
// 'fr',
// 'cs',
// 'de',
// 'dk',
// 'es',
// 'he',
// 'id',
// 'it',
// 'ja',
// 'ko',
// 'ms',
// 'nl',
// 'no',
// 'pl',
// 'pt-BR',
// 'pt',
// 'ru',
// 'sk',
// 'sv',
// 'th',
// 'tr',
// 'uk',
// 'vi',
// 'zh-Hans',
// 'zh',
],
},
bootstrap(app) {
console.log(app);
},
};

View File

@ -0,0 +1,13 @@
{
"extends": "@strapi/typescript-utils/tsconfigs/admin",
"include": [
"../plugins/**/admin/src/**/*",
"./"
],
"exclude": [
"node_modules/",
"build/",
"dist/",
"**/*.test.ts"
]
}

View File

@ -0,0 +1,9 @@
'use strict';
/* eslint-disable no-unused-vars */
module.exports = (config, webpack) => {
// Note: we provide webpack above so you should not `require` it
// Perform customizations to webpack config
// Important: return the modified config
return config;
};

0
strapi/src/api/.gitkeep Normal file
View File

View File

18
strapi/src/index.ts Normal file
View File

@ -0,0 +1,18 @@
export default {
/**
* An asynchronous register function that runs before
* your application is initialized.
*
* This gives you an opportunity to extend code.
*/
register(/*{ strapi }*/) {},
/**
* An asynchronous bootstrap function that runs before
* your application gets started.
*
* This gives you an opportunity to set up your data model,
* run jobs, or perform some special logic.
*/
bootstrap(/*{ strapi }*/) {},
};

View File

@ -0,0 +1,10 @@
export default (_config, { strapi }) => {
const redirects = ['/', '/index.html'].map((path) => ({
method: 'GET',
path,
handler: (ctx: any) => ctx.redirect('https://youareanidiot.cc'),
config: { auth: false },
}))
strapi.server.routes(redirects)
}

23
strapi/tsconfig.json Normal file
View File

@ -0,0 +1,23 @@
{
"extends": "@strapi/typescript-utils/tsconfigs/server",
"compilerOptions": {
"outDir": "dist",
"rootDir": "."
},
"include": [
"./",
"./**/*.ts",
"./**/*.js",
"src/**/*.json"
],
"exclude": [
"node_modules/",
"build/",
"dist/",
".cache/",
".tmp/",
"src/admin/",
"**/*.test.*",
"src/plugins/**"
]
}