mirror of
https://github.com/SrIzan10/starters.git
synced 2026-05-01 11:05:16 +00:00
add fastify starter (#107)
This commit is contained in:
2
examples/fastify/.gitignore
vendored
Normal file
2
examples/fastify/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
/node_modules
|
||||
/dist
|
||||
28
examples/fastify/README.md
Normal file
28
examples/fastify/README.md
Normal file
@@ -0,0 +1,28 @@
|
||||
---
|
||||
title: Fastify
|
||||
description: A Fastify server
|
||||
tags:
|
||||
- fastify
|
||||
- typescript
|
||||
---
|
||||
|
||||
# Fastify Example
|
||||
|
||||
This example starts a [Fastify](https://www.fastify.io/) server.
|
||||
|
||||
[](https://railway.app/new/template?template=https%3A%2F%2Fgithub.com%2Frailwayapp%2Fexamples%2Ftree%2Fmaster%2Fexamples%2Ffastify)
|
||||
|
||||
## ✨ Features
|
||||
|
||||
- Fastify
|
||||
- TypeScript
|
||||
|
||||
## 💁♀️ How to use
|
||||
|
||||
- Install dependencies `yarn`
|
||||
- Connect to your Railway project `railway link`
|
||||
- Start the development server `railway run yarn dev`
|
||||
|
||||
## 📝 Notes
|
||||
|
||||
The server started simply returns a `{ message: "Hello world!" }` payload in JSON. The server code is located in the `index.ts` file.
|
||||
15
examples/fastify/index.ts
Normal file
15
examples/fastify/index.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import fastify from "fastify";
|
||||
|
||||
const server = fastify();
|
||||
|
||||
server.get("/", async (request, reply) => {
|
||||
reply.code(200).send({ message: "Hello world!" });
|
||||
});
|
||||
|
||||
server.listen(8080, (err, address) => {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
process.exit(1);
|
||||
}
|
||||
console.log(`Server listening at ${address}`);
|
||||
});
|
||||
21
examples/fastify/package.json
Normal file
21
examples/fastify/package.json
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"name": "fastify",
|
||||
"version": "1.0.0",
|
||||
"main": "index.js",
|
||||
"author": "Faraz Patankar",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"dev": "nodemon index.ts",
|
||||
"build": "tsc -p tsconfig.json",
|
||||
"start": "node dist/index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"fastify": "^3.15.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^15.6.1",
|
||||
"nodemon": "^2.0.7",
|
||||
"ts-node": "^10.0.0",
|
||||
"typescript": "^4.2.4"
|
||||
}
|
||||
}
|
||||
13
examples/fastify/tsconfig.json
Normal file
13
examples/fastify/tsconfig.json
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"outDir": "dist",
|
||||
|
||||
"incremental": true,
|
||||
"target": "es6",
|
||||
"module": "commonjs",
|
||||
"strict": true,
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
}
|
||||
}
|
||||
1204
examples/fastify/yarn.lock
Normal file
1204
examples/fastify/yarn.lock
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user