Compare commits

..

4 Commits

Author SHA1 Message Date
529ebb2a8f clean up initial route sample
ref #1
2020-11-24 20:08:30 +01:00
f854f137e5 gitignore /build folder - ref #1 2020-11-24 20:07:55 +01:00
3c389937b7 move orm config to src folder
ref #2
2020-11-24 20:07:41 +01:00
0b92d82a5b tsc building script
ref #1
2020-11-24 20:07:09 +01:00
5 changed files with 18 additions and 23 deletions

1
.gitignore vendored
View File

@ -128,3 +128,4 @@ dist
.pnp.* .pnp.*
yarn.lock yarn.lock
package-lock.json package-lock.json
build

View File

@ -1,11 +0,0 @@
import { config } from "dotenv-safe";
config();
export default {
"type": process.env.DB_TYPE,
"host": process.env.DB_HOST,
"port": process.env.DB_PORT,
"username": process.env.DB_USER,
"password": process.env.DB_PASSWORD,
"database": process.env.DB_NAME
}

View File

@ -24,6 +24,7 @@
"typescript": "^4.1.2" "typescript": "^4.1.2"
}, },
"scripts": { "scripts": {
"dev": "nodemon src/app.ts" "dev": "nodemon src/app.ts",
"build": "tsc"
} }
} }

View File

@ -9,18 +9,11 @@ const app = express();
const PORT = process.env.APP_PORT || 4010; const PORT = process.env.APP_PORT || 4010;
createConnection() createConnection()
.then((connection) => { .then((connection) => {})
app.get('/', (req, res) => {
const encoded = jwt.sign({ key: 'value' }, 'secret');
consola.info(encoded);
return res.send('Express + TypeScript Server');
});
app.listen(PORT, () => {
consola.success(`⚡️[server]: Server is running at http://localhost:${PORT}`);
});
})
.catch((err) => { .catch((err) => {
consola.error(err); consola.error(err);
})
.finally(() => {
app.get('/', (req, res) => { app.get('/', (req, res) => {
const encoded = jwt.sign({ key: 'value' }, 'secret'); const encoded = jwt.sign({ key: 'value' }, 'secret');
consola.info(encoded); consola.info(encoded);

11
src/ormconfig.ts Normal file
View File

@ -0,0 +1,11 @@
import { config } from 'dotenv-safe';
config();
export default {
type: process.env.DB_TYPE,
host: process.env.DB_HOST,
port: process.env.DB_PORT,
username: process.env.DB_USER,
password: process.env.DB_PASSWORD,
database: process.env.DB_NAME
};