Add config options for mongo auth and server port
This commit is contained in:
6
.env.example
Normal file
6
.env.example
Normal file
@@ -0,0 +1,6 @@
|
||||
PAYLOAD_SECRET=
|
||||
MONGODB_HOST=localhost
|
||||
MONGODB_DB=summer-dci
|
||||
MONGODB_USER=
|
||||
MONGODB_PASS=
|
||||
LISTEN_PORT=3000
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -4,3 +4,4 @@ build/
|
||||
.env
|
||||
src/media
|
||||
.eslintcache
|
||||
.*.swp
|
||||
|
||||
@@ -4,7 +4,7 @@ import path from 'path';
|
||||
import Users from './collections/Users';
|
||||
|
||||
export default buildConfig({
|
||||
serverURL: 'http://localhost:3001',
|
||||
serverURL: 'https://summer.mattfidd.rocks',
|
||||
admin: {
|
||||
user: Users.slug
|
||||
},
|
||||
|
||||
@@ -7,13 +7,25 @@ dotenv.config();
|
||||
|
||||
const app = express();
|
||||
|
||||
const generateMongoURI = (): string => {
|
||||
return (
|
||||
'mongodb://' +
|
||||
(process.env.MONGODB_USER ?
|
||||
`${process.env.MONGODB_USER}:${process.env.MONGODB_PASS}@` :
|
||||
''
|
||||
) +
|
||||
`${process.env.MONGODB_HOST}/` +
|
||||
process.env.MONGODB_DB
|
||||
);
|
||||
};
|
||||
|
||||
payload.init({
|
||||
secret: process.env.PAYLOAD_SECRET,
|
||||
mongoURL: process.env.MONGODB_URI,
|
||||
mongoURL: generateMongoURI(),
|
||||
express: app,
|
||||
onInit: () => {
|
||||
payload.logger.info(`Payload Admin URL: ${payload.getAdminURL()}`);
|
||||
}
|
||||
});
|
||||
|
||||
app.listen(3001);
|
||||
app.listen(process.env.LISTEN_PORT);
|
||||
|
||||
Reference in New Issue
Block a user