Skip to content

Commit fa0184e

Browse files
author
Kendall Roden
committed
initial commit
1 parent 2064939 commit fa0184e

File tree

12 files changed

+1192
-67
lines changed

12 files changed

+1192
-67
lines changed

.dockerignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
**/.classpath
2+
**/.dockerignore
3+
**/.env
4+
**/.git
5+
**/.gitignore
6+
**/.project
7+
**/.settings
8+
**/.toolstarget
9+
**/.vs
10+
**/.vscode
11+
**/*.*proj.user
12+
**/*.dbmdl
13+
**/*.jfm
14+
**/charts
15+
**/docker-compose*
16+
**/compose*
17+
**/Dockerfile*
18+
**/node_modules
19+
**/npm-debug.log
20+
**/obj
21+
**/secrets.dev.yaml
22+
**/values.dev.yaml
23+
README.md

.vscode/launch.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "Node Album API",
9+
"request": "launch",
10+
"runtimeArgs": ["run", "start"],
11+
"runtimeExecutable": "npm",
12+
"skipFiles": ["<node_internals>/**"],
13+
"type": "pwa-node",
14+
"cwd": "${workspaceFolder}/",
15+
"console": "integratedTerminal",
16+
"serverReadyAction": {
17+
"action": "openExternally"
18+
}
19+
}
20+
]
21+
}

CHANGELOG.md

Lines changed: 0 additions & 13 deletions
This file was deleted.

Dockerfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM node:lts-alpine
2+
ENV NODE_ENV=production
3+
WORKDIR /usr/src/app
4+
COPY ["package.json", "package-lock.json*", "npm-shrinkwrap.json*", "./"]
5+
RUN npm install --production --silent && mv node_modules ../
6+
COPY . .
7+
EXPOSE 3000
8+
RUN chown -R node /usr/src/app
9+
USER node
10+
CMD ["npm", "start"]

README.md

Lines changed: 5 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,8 @@
1-
# Project Name
1+
# Azure Container Apps Album API
22

3-
(short, 1-3 sentenced, description of the project)
3+
This is the companion repository for the [Azure Container Apps code-to-cloud quickstart]().
44

5-
## Features
5+
This backend Album API sample is available in other languages:
66

7-
This project framework provides the following features:
8-
9-
* Feature 1
10-
* Feature 2
11-
* ...
12-
13-
## Getting Started
14-
15-
### Prerequisites
16-
17-
(ideally very short, if any)
18-
19-
- OS
20-
- Library version
21-
- ...
22-
23-
### Installation
24-
25-
(ideally very short)
26-
27-
- npm install [package name]
28-
- mvn install
29-
- ...
30-
31-
### Quickstart
32-
(Add steps to get up and running quickly)
33-
34-
1. git clone [repository clone url]
35-
2. cd [repository name]
36-
3. ...
37-
38-
39-
## Demo
40-
41-
A demo app is included to show how to use the project.
42-
43-
To run the demo, follow these steps:
44-
45-
(Add steps to start up the demo)
46-
47-
1.
48-
2.
49-
3.
50-
51-
## Resources
52-
53-
(Any additional resources or related projects)
54-
55-
- Link to supporting information
56-
- Link to similar sample
57-
- ...
7+
| [C#](https://github.com/azure-samples/containerapps-albumapi-csharp) | [Go](https://github.com/azure-samples/containerapps-albumapi-go) | [Python](https://github.com/azure-samples/containerapps-albumapi-python) |
8+
| -------------------------------------------------------------------- | ---------------------------------------------------------------- | ------------------------------------------------------------------------ |

app.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
var express = require("express");
2+
var path = require("path");
3+
var logger = require("morgan");
4+
5+
var router = require("./routes/index");
6+
const appPort = process.env.PORT || 3000;
7+
var app = express();
8+
9+
//enable cors
10+
app.use(function (req, res, next) {
11+
res.header("Access-Control-Allow-Origin", "*");
12+
res.header(
13+
"Access-Control-Allow-Headers",
14+
"Origin, X-Requested-With, Content-Type, Accept"
15+
);
16+
next();
17+
});
18+
app.use(logger("dev"));
19+
app.use(express.json({ type: ["applicaton/json"] }));
20+
app.use(express.urlencoded({ extended: false }));
21+
app.use("/", router);
22+
23+
console.log("Container Apps Node Sample");
24+
module.exports = app;

controllers/AlbumController.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
var Albums = require("../models/Album");
2+
3+
exports.index = async function (req, res) {
4+
const albums = await Albums.getAlbums();
5+
console.log("Retrieved Albums");
6+
res.json(albums);
7+
};

models/Album.js

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
const albums = [
2+
{
3+
id: 1,
4+
title: "Sgt Peppers Lonely Hearts Club Band",
5+
artist: "The Beatles",
6+
price: 56.99,
7+
image_url:
8+
"https://www.listchallenges.com/f/items/f3b05a20-31ae-4fdf-aebd-d1515af54eea.jpg",
9+
},
10+
{
11+
id: 2,
12+
title: "Pet Sounds",
13+
artist: "The Beach Boys",
14+
price: 17.99,
15+
image_url:
16+
"https://www.listchallenges.com/f/items/fdef1440-e979-455a-90a7-14e77fac79af.jpg",
17+
},
18+
{
19+
id: 3,
20+
title: "The Beatles: Revolver",
21+
artist: "The Beatles",
22+
price: 39.99,
23+
image_url:
24+
"https://www.listchallenges.com/f/items/19ff786d-d7a4-4fdc-bee2-59db8b33370d.jpg",
25+
},
26+
{
27+
id: 4,
28+
title: "Highway 61 Revisited",
29+
artist: "Bob Dylan",
30+
price: 39.99,
31+
image_url:
32+
"https://www.listchallenges.com/f/items/428cf087-6c24-45ad-bf8c-bd3c57ddf444.jpg",
33+
},
34+
{
35+
id: 5,
36+
title: "Rubber Soul",
37+
artist: "The Beatles",
38+
price: 39.99,
39+
image_url:
40+
"https://www.listchallenges.com/f/items/ebc794ef-1491-4672-a007-0081edc1a8ae.jpg",
41+
},
42+
{
43+
id: 6,
44+
title: "What's Going On",
45+
artist: "Marvin Gaye",
46+
price: 39.99,
47+
image_url:
48+
"https://www.listchallenges.com/f/items/e5250d6c-1c15-4617-a943-b27e87e21704.jpg",
49+
},
50+
];
51+
52+
const getAlbums = async function () {
53+
return Promise.resolve(albums);
54+
};
55+
56+
exports.getAlbums = getAlbums;

0 commit comments

Comments
 (0)