Skip to content

Commit 71551b6

Browse files
committed
Remove nextjs-boilerplate sample
0 parents  commit 71551b6

File tree

7 files changed

+778
-0
lines changed

7 files changed

+778
-0
lines changed

.github/workflows/deploy.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Deploy
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
deploy:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: read
13+
id-token: write
14+
15+
steps:
16+
- name: Checkout Repo
17+
uses: actions/checkout@v4
18+
19+
- name: Deploy
20+
uses: DefangLabs/[email protected]

README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Node.js & Express
2+
3+
[![1-click-deploy](https://defang.io/deploy-with-defang.png)](https://portal.defang.dev/redirect?url=https%3A%2F%2Fgithub.com%2Fnew%3Ftemplate_name%3Dsample-nodejs-express-template%26template_owner%3DDefangSamples)
4+
5+
This Node.js application, built with Express.js, is designed to inspect and display detailed information about incoming HTTP requests. It supports all HTTP methods and provides insights into the request path, method, headers, query parameters, and body. Note alongside your project, you should also include a package.json file that includes the relevant metadata such as package dependencies, scripts, project verrsions so that the Dockerfile can install necessary dependencies.
6+
7+
## Essential Setup Files
8+
9+
1. A [Dockerfile](https://docs.docker.com/develop/develop-images/dockerfile_best-practices/).
10+
2. A [compose file](https://docs.defang.io/docs/concepts/compose) to define and run multi-container Docker applications (this is how Defang identifies services to be deployed).
11+
12+
## Prerequisite
13+
14+
1. Download [Defang CLI](https://github.com/DefangLabs/defang)
15+
2. If you are using [Defang BYOC](https://docs.defang.io/docs/concepts/defang-byoc), make sure you have properly [authenticated your AWS account (optional)](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html)
16+
17+
## A Step-by-Step Guide
18+
19+
1. Open the terminal and type `defang login`
20+
2. Type `defang compose up` in the CLI
21+
3. Your app should be up and running with Defang in minutes!
22+
23+
---
24+
25+
Title: Node.js & Express
26+
27+
Short Description: A Node.js application that inspects and displays detailed information about incoming http requests.
28+
29+
Tags: Node.js, Express, http, Request, Inspector, JavaScript
30+
31+
Languages: nodejs

app/Dockerfile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Use the slim version of Node.js on Debian Bookworm as the base image
2+
FROM node:20-bookworm-slim
3+
4+
RUN apt-get update && apt-get install -y curl
5+
6+
# Set the working directory to /app
7+
WORKDIR /app
8+
9+
# Copy package.json and package-lock.json into the container at /app
10+
COPY package*.json ./
11+
12+
# Install any needed packages specified in package.json
13+
RUN npm ci
14+
15+
# Copy the current directory contents into the container at /app
16+
COPY . .
17+
18+
# Make port 3000 available to the world outside this container
19+
EXPOSE 3000
20+
21+
# Run the app when the container launches
22+
ENTRYPOINT ["node", "main.js"]

app/main.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
const express = require('express');
2+
const app = express();
3+
const bodyParser = require('body-parser');
4+
5+
app.use(bodyParser.json());
6+
app.use(bodyParser.urlencoded({ extended: true }));
7+
8+
app.all("/", (req, res) => {
9+
res.send({
10+
"path" : req.path,
11+
"method" : req.method,
12+
"headers" : req.headers,
13+
"args" : req.query,
14+
"body" : req.body
15+
});
16+
});
17+
18+
app.listen(3000, () => {
19+
console.log('Server started on port 3000');
20+
});

0 commit comments

Comments
 (0)