Skip to content

Commit fee9c8b

Browse files
Initial project setup
1 parent 590967b commit fee9c8b

File tree

7 files changed

+253
-86
lines changed

7 files changed

+253
-86
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
.arc-env
22
.DS_Store
33
node_modules
4+
.vscode/

.prettierrc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"printWidth": 100,
3+
"tabWidth": 2,
4+
"useTabs": false,
5+
"semi": true,
6+
"singleQuote": false,
7+
"trailingComma": "all",
8+
"bracketSpacing": true,
9+
"arrowParens": "always"
10+
}

app.arc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
@app
2-
begin-app
2+
writes-functions
33

44
@http
55
get /

package-lock.json

Lines changed: 85 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
{
2-
"name": "begin-app",
3-
"version": "0.0.0",
4-
"description": "Begin basic Hello World! app for Node",
2+
"name": "writes-functions",
3+
"version": "0.1.0",
4+
"description": "writes. functions",
55
"scripts": {
66
"start": "cross-env NODE_ENV=testing npx sandbox"
77
},
88
"devDependencies": {
99
"@architect/sandbox": "latest",
1010
"cross-env": "^7.0.2"
11+
},
12+
"dependencies": {
13+
"@architect/functions": "^3.12.1"
1114
}
1215
}

src/http/get-index/index.js

Lines changed: 7 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,11 @@
1-
// Add simple, fast, scalable persistence: https://docs.begin.com/en/data/begin-data/
2-
// let data = require('@begin/data')
1+
const arc = require('@architect/functions');
32

4-
// Add secure sessions, middleware, and more: https://docs.begin.com/en/functions/http/
5-
// let arc = require('@architect/functions')
6-
7-
// TODO: modify the body object!
8-
let body = `
9-
<!doctype html>
10-
<html lang=en>
11-
<head>
12-
<meta charset=utf-8>
13-
<title>Hi!</title>
14-
<link rel="stylesheet" href="https://static.begin.app/starter/default.css">
15-
<link href="data:image/x-icon;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=" rel="icon" type="image/x-icon">
16-
</head>
17-
<body>
18-
19-
<h1 class="center-text">
20-
<!-- ↓ Change "Hello world!" to something else and head on back to Begin! -->
21-
Hello world!
22-
</h1>
23-
24-
<p class="center-text">
25-
Your <a href="https://begin.com" class="link" target="_blank">Begin</a> app is ready to go!
26-
</p>
27-
28-
</body>
29-
</html>
30-
`
31-
32-
exports.handler = async function http(req) {
33-
return {
34-
headers: {
35-
'content-type': 'text/html; charset=utf8',
36-
'cache-control': 'no-cache, no-store, must-revalidate, max-age=0, s-maxage=0'
3+
function route(req, res) {
4+
res({
5+
json: {
6+
message: 'hello world!',
377
},
38-
body
39-
}
8+
});
409
}
4110

42-
// Example responses
43-
44-
/* Forward requester to a new path
45-
exports.handler = async function http (req) {
46-
return {
47-
statusCode: 302,
48-
headers: {'location': '/about'}
49-
}
50-
}
51-
*/
52-
53-
/* Respond with successful resource creation, CORS enabled
54-
let arc = require('@architect/functions')
55-
exports.handler = arc.http.async (http)
56-
async function http (req) {
57-
return {
58-
statusCode: 201,
59-
headers: {'content-type': 'application/json; charset=utf8'},
60-
body: JSON.stringify({ok: true}),
61-
cors: true,
62-
}
63-
}
64-
*/
65-
66-
/* Deliver client-side JS
67-
exports.handler = async function http (req) {
68-
return {
69-
headers: {'content-type': 'text/javascript; charset=utf8'},
70-
body: 'console.log("Hello world!")',
71-
}
72-
}
73-
*/
11+
exports.handler = arc.http(route);

0 commit comments

Comments
 (0)