add strapi example (#108)

* add strapi example

* add missing packages

* update README
This commit is contained in:
Faraz Patankar
2021-05-26 09:34:10 +04:00
committed by GitHub
parent 8ff32051c4
commit 087623e01e
19 changed files with 11061 additions and 0 deletions

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

View File

@@ -0,0 +1,3 @@
.cache
build
**/node_modules/**

27
examples/strapi/.eslintrc Normal file
View File

@@ -0,0 +1,27 @@
{
"parser": "babel-eslint",
"extends": "eslint:recommended",
"env": {
"commonjs": true,
"es6": true,
"node": true,
"browser": false
},
"parserOptions": {
"ecmaFeatures": {
"experimentalObjectRestSpread": true,
"jsx": false
},
"sourceType": "module"
},
"globals": {
"strapi": true
},
"rules": {
"indent": ["error", 2, { "SwitchCase": 1 }],
"linebreak-style": ["error", "unix"],
"no-console": 0,
"quotes": ["error", "single"],
"semi": ["error", "always"]
}
}

114
examples/strapi/.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
############################
testApp
coverage
############################
# Strapi
############################
.env
license.txt
exports
*.cache
build
.strapi-updater.json

30
examples/strapi/README.md Normal file
View File

@@ -0,0 +1,30 @@
---
title: Strapi
description: A self-hosted version of Strapie using a Postgres database
tags:
- strapi
- postgres
- cms
---
# Strapi example
This example deploys self-hosted version of [Strapi](https://strapi.io/). Internally it uses a MySQL database to store the data.
[![Deploy on Railway](https://railway.app/button.svg)](https://railway.app/new/template?template=https%3A%2F%2Fgithub.com%2Frailwayapp%2Fexamples%2Ftree%2Fmaster%2Fexamples%2Fstrapi&plugins=postgresql&envs=ADMIN_JWT_SECRET%2CCLOUDINARY_NAME%2CCLOUDINARY_KEY%2CCLOUDINARY_SECRET&optionalEnvs=CLOUDINARY_NAME%2CCLOUDINARY_KEY%2CCLOUDINARY_SECRET&ADMIN_JWT_SECRETDesc=Secret+used+to+encode+JWT+tokens)
## ✨ Features
- Strapi
- Postgres
## 💁‍♀️ How to use
- Click the Railway button 👆
- Add the environment variables
- If you do not add the Cloudinary related environment variables, your images/files will not be persisted between deploys.
## 📝 Notes
- After your app is deployed, visit the `/admin` endpoint to create your admin user.
- Railway's filesystem is ephemeral which is why any changes to the filesystem are not persisted between deploys. This is why, this example uses Cloudinary for storage.

View File

View File

@@ -0,0 +1,19 @@
module.exports = ({ env }) => ({
defaultConnection: "default",
connections: {
default: {
connector: "bookshelf",
settings: {
client: "postgres",
host: env("PGHOST", "localhost"),
port: env.int("PGPORT", 5432),
database: env("PGDATABASE", "strapi"),
username: env("PGUSER", "strapi"),
password: env("PGPASSWORD", "strapi"),
schema: env("DATABASE_SCHEMA", "public"), // Not Required
ssl: false,
},
options: {},
},
},
});

View File

@@ -0,0 +1,13 @@
'use strict';
/**
* 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.
*
* See more details here: https://strapi.io/documentation/developer-docs/latest/setup-deployment-guides/configurations.html#bootstrap
*/
module.exports = () => {};

View File

@@ -0,0 +1,21 @@
'use strict';
/**
* Cron config that gives you an opportunity
* to run scheduled jobs.
*
* The cron format consists of:
* [SECOND (optional)] [MINUTE] [HOUR] [DAY OF MONTH] [MONTH OF YEAR] [DAY OF WEEK]
*
* See more details here: https://strapi.io/documentation/developer-docs/latest/setup-deployment-guides/configurations.html#cron-tasks
*/
module.exports = {
/**
* Simple example.
* Every monday at 1am.
*/
// '0 1 * * 1': () => {
//
// }
};

View File

@@ -0,0 +1,5 @@
'use strict';
module.exports = async (/* ctx */) => {
// return ctx.notFound('My custom message 404');
};

View File

@@ -0,0 +1,10 @@
module.exports = ({ env }) => ({
upload: {
provider: "cloudinary",
providerOptions: {
cloud_name: env("CLOUDINARY_NAME"),
api_key: env("CLOUDINARY_KEY"),
api_secret: env("CLOUDINARY_SECRET"),
},
},
});

View File

@@ -0,0 +1,9 @@
module.exports = ({ env }) => ({
host: env("HOST", "0.0.0.0"),
port: env.int("PORT", 1337),
admin: {
auth: {
secret: env("ADMIN_JWT_SECRET"),
},
},
});

View File

View File

@@ -0,0 +1,3 @@
module.exports = {
jwtSecret: process.env.JWT_SECRET || '89fdff6d-024c-4d9e-bab1-5288460e4a34'
};

BIN
examples/strapi/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

View File

@@ -0,0 +1,39 @@
{
"name": "strapi",
"private": true,
"version": "0.1.0",
"description": "A Strapi application",
"scripts": {
"develop": "strapi develop",
"start": "strapi start",
"build": "strapi build",
"strapi": "strapi"
},
"devDependencies": {},
"dependencies": {
"knex": "0.21.18",
"pg": "^8.6.0",
"strapi": "3.6.2",
"strapi-admin": "3.6.2",
"strapi-connector-bookshelf": "3.6.2",
"strapi-plugin-content-manager": "3.6.2",
"strapi-plugin-content-type-builder": "3.6.2",
"strapi-plugin-email": "3.6.2",
"strapi-plugin-i18n": "3.6.2",
"strapi-plugin-upload": "3.6.2",
"strapi-plugin-users-permissions": "3.6.2",
"strapi-provider-upload-cloudinary": "^3.6.2",
"strapi-utils": "3.6.2"
},
"author": {
"name": "A Strapi developer"
},
"strapi": {
"uuid": "4429591a-1258-4c86-bb9d-98a9dbd0eb1d"
},
"engines": {
"node": ">=10.16.0 <=14.x.x",
"npm": "^6.0.0"
},
"license": "MIT"
}

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

10749
examples/strapi/yarn.lock Normal file

File diff suppressed because it is too large Load Diff