Add config options for mongo auth and server port

This commit is contained in:
2022-07-22 01:57:37 +00:00
parent 71b854d51a
commit 9060ffbcc0
4 changed files with 23 additions and 4 deletions

6
.env.example Normal file
View File

@@ -0,0 +1,6 @@
PAYLOAD_SECRET=
MONGODB_HOST=localhost
MONGODB_DB=summer-dci
MONGODB_USER=
MONGODB_PASS=
LISTEN_PORT=3000

3
.gitignore vendored
View File

@@ -3,4 +3,5 @@ dist/
build/
.env
src/media
.eslintcache
.eslintcache
.*.swp

View File

@@ -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
},

View File

@@ -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);