Skip to content
This repository has been archived by the owner on Nov 23, 2024. It is now read-only.

Commit

Permalink
Update examples README
Browse files Browse the repository at this point in the history
  • Loading branch information
Samrith Shankar committed Feb 22, 2020
1 parent 723d41b commit 979af13
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 4 deletions.
6 changes: 3 additions & 3 deletions examples/express-javascript/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,6 @@ app.listen(process.env.PORT, () => {
yarn start
```

And, voila! Your Express server with the latest ES support is up and running!
You can make any changes and hit save, and check your terminal. Nodehawk will
promptly restart the process to reflect your changes!
Et voila! Your Express server with the latest ES support is up and running. You
can make any changes and hit save, and check your terminal. Nodehawk will
promptly restart the process to reflect your changes.
79 changes: 78 additions & 1 deletion examples/express-typescript/README.md
Original file line number Diff line number Diff line change
@@ -1 +1,78 @@
COMING SOON!
# Express Typescript server with Nodehawk

Creating an Express server written in Typescript from scratch, with Nodemon
watching for changes, is very simple.

- Install express

```bash
yarn add express
```

- Install development dependencies

```bash
yarn add -D nodehawk typescript @types/express @types/node ts-node
```

- Create a `tsconfig.json` in your project root.

```json
{
"include": ["./src/**/*.ts", "./src/**/*.json"],
"exclude": ["node_modules"],
"compilerOptions": {
"baseUrl": "src",
"outDir": "build",
"rootDir": ".",
"module": "commonjs",
"target": "es2015"
}
}
```

- Create a `.nodehawkrc` in your project root.

```jsonc
{
"exec": "ts-node src/server",
"port": 1337 // this is optional. Default port is 4000.
}
```

- Create your server in `src/server.ts`. Not the usage of `process.env.PORT`.
This is very important to get the utmost out of Nodehawk.

```typescript
import express from "express";

const app = express();

app.get("/", (req, res) => {
res.send("Hello world");
});

app.listen(process.env.PORT, () => {
console.log(`App running on http://localhost:${process.env.PORT}`);
});
```

- Add a script in your `package.json`.

```jsonc
{
"scripts": {
"start": "nodehawk" // Yes, really
}
}
```

- Run the script.

```bash
yarn start
```

Et voila! Your Express server with the latest Typescript and ES support is up
and running. You can make any changes and hit save, and check your terminal.
Nodehawk will promptly restart the process to reflect your changes.

0 comments on commit 979af13

Please sign in to comment.