Skip to content

Commit 4beaa3c

Browse files
shidilcrcastle
andauthored
Upgrade to strapi v4 (#13)
* Updated package.json with v4 deps * Updated folder structure to match v4 quickstart * Updated config files for v4 * Bump strapi to 4.1.0 * Use strapi recommended middleware config for cloudinary * Move ADMIN_JWT_SECRET out of code to avoid leaking * Upgrade to 4.1.3 * Remove unnecessary file * Upgrade pg * Upgrade node version * Add placeholder for all env vars * Add APP_KEYS to render.yaml This is required for 4.0.6 and later * Add session middleware required for > v4.0.6 * Re-add setting server.url in production Co-authored-by: Chris Castle <chris@render.com>
1 parent 8c688b9 commit 4beaa3c

File tree

25 files changed

+4707
-4538
lines changed

25 files changed

+4707
-4538
lines changed

.env.example

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,10 @@
11
HOST=0.0.0.0
22
PORT=1337
3+
APP_KEYS=testkey
4+
ADMIN_JWT_SECRET=testsecret
5+
API_TOKEN_SALT=testsalt
6+
# The following are only needed in production
7+
# Media is stored on the filesystem in development
8+
#CLOUDINARY_NAME=
9+
#CLOUDINARY_KEY=
10+
#CLOUDINARY_SECRET=

config/admin.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = ({ env }) => ({
2+
auth: {
3+
secret: env('ADMIN_JWT_SECRET'),
4+
},
5+
});

config/api.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = {
2+
rest: {
3+
defaultLimit: 25,
4+
maxLimit: 100,
5+
withCount: true,
6+
},
7+
};

config/database.js

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
1+
const path = require('path');
2+
13
module.exports = ({ env }) => ({
2-
defaultConnection: 'default',
3-
connections: {
4-
default: {
5-
connector: 'bookshelf',
6-
settings: {
7-
client: 'sqlite',
8-
filename: env('DATABASE_FILENAME', '.tmp/data.db'),
9-
},
10-
options: {
11-
useNullAsDefault: true,
12-
},
4+
connection: {
5+
client: 'sqlite',
6+
connection: {
7+
filename: path.join(__dirname, '..', env('DATABASE_FILENAME', '.tmp/data.db')),
138
},
9+
useNullAsDefault: true,
1410
},
1511
});
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// https://docs.strapi.io/developer-docs/latest/setup-deployment-guides/configurations/optional/cronjobs.html#creating-a-cron-job
2+
3+
module.exports = {
4+
/**
5+
* Simple example.
6+
* Every monday at 1am.
7+
*/
8+
9+
// '0 0 1 * * 1': ({ strapi }) => {
10+
// // Add your own logic here (e.g. send a queue of email, create a database backup, etc.).
11+
// },
12+
};

config/env/production/database.js

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,16 @@ module.exports = ({ env }) => {
44
const { host, port, database, user, password } = parse(env("DATABASE_URL"));
55

66
return {
7-
defaultConnection: "default",
8-
connections: {
9-
default: {
10-
connector: "bookshelf",
11-
settings: {
12-
client: "postgres",
13-
host,
14-
port,
15-
database,
16-
username: user,
17-
password,
18-
},
7+
connection: {
8+
client: "postgres",
9+
connection: {
10+
host,
11+
port,
12+
database,
13+
user,
14+
password
1915
},
16+
debug: false,
2017
},
2118
};
2219
};

config/env/production/logger.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
"use strict";
2+
3+
const { winston } = require("@strapi/logger");
4+
5+
module.exports = {
6+
transports: [
7+
new winston.transports.Console({
8+
level: "error",
9+
}),
10+
],
11+
};

config/env/production/middleware.js

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
module.exports = [
2+
"strapi::errors",
3+
{
4+
name: "strapi::security",
5+
config: {
6+
contentSecurityPolicy: {
7+
useDefaults: true,
8+
directives: {
9+
"connect-src": ["'self'", "https:"],
10+
"img-src": ["'self'", "data:", "blob:", "res.cloudinary.com"],
11+
"media-src": ["'self'", "data:", "blob:", "res.cloudinary.com"],
12+
upgradeInsecureRequests: null,
13+
},
14+
},
15+
},
16+
},
17+
"strapi::cors",
18+
"strapi::poweredBy",
19+
"strapi::logger",
20+
"strapi::query",
21+
"strapi::body",
22+
'strapi::session',
23+
"strapi::favicon",
24+
"strapi::public",
25+
];

config/env/production/plugins.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
module.exports = ({ env }) => ({
22
upload: {
3-
provider: "cloudinary",
4-
providerOptions: {
5-
cloud_name: env("CLOUDINARY_NAME"),
6-
api_key: env("CLOUDINARY_KEY"),
7-
api_secret: env("CLOUDINARY_SECRET"),
3+
config: {
4+
provider: "cloudinary",
5+
providerOptions: {
6+
cloud_name: env("CLOUDINARY_NAME"),
7+
api_key: env("CLOUDINARY_KEY"),
8+
api_secret: env("CLOUDINARY_SECRET"),
9+
},
810
},
911
},
1012
});

0 commit comments

Comments
 (0)