Skip to content

Commit 2b3a562

Browse files
committed
updating examples to use props over args change
1 parent 4c3cc1d commit 2b3a562

46 files changed

Lines changed: 109 additions & 109 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

examples/with-entries/src/events/error.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { action } from '@stackpress/ingest';
22

3-
export default action(function Error(req, res) {
3+
export default action(function Error({ req, res }) {
44
const html = [ `<h1>${res.error}</h1>` ];
55
const stack = res.stack?.map((log, i) => {
66
const { line, char } = log;

examples/with-entries/src/plugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export default function plugin(server: HttpServer<Config>) {
2828
server.entry.on('error', path.join(__dirname, 'events/error'));
2929

3030
server.register('project', { welcome: 'Hello, World!!' });
31-
server.on('request', (req, res) => {
31+
server.on('request', ({ req, res }) => {
3232
console.log('Request:', req.url);
3333
});
3434
}

examples/with-entries/src/routes/404.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { action } from '@stackpress/ingest';
22

3-
export default action(function NotFound(req, res) {
3+
export default action(function NotFound({ req, res }) {
44
if (!res.code && !res.status && !res.sent) {
55
//send the response
66
res.setHTML('Not Found');

examples/with-entries/src/routes/catch.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { action, Status, Exception } from '@stackpress/ingest';
22

3-
export default action(function ErrorResponse(req, res) {
3+
export default action(function ErrorResponse({ req, res }) {
44
try {
55
throw Exception.for('Not implemented');
66
} catch (e) {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { action } from '@stackpress/ingest';
22
import Error from '../error';
33

4-
export default action(function ErrorResponse(req, res) {
4+
export default action(function ErrorResponse({ req, res }) {
55
Error('Not implemented');
66
});
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { action } from '@stackpress/ingest';
22

3-
export default action(async function HomePage(req, res, ctx) {
3+
export default action(async function HomePage({ req, res, ctx }) {
44
const project = ctx.plugin<{ welcome: string }>('project');
55
res.setHTML(project.welcome);
66
});

examples/with-entries/src/routes/icon.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import fs from 'node:fs';
22
import path from 'node:path';
33
import { action } from '@stackpress/ingest';
44

5-
export default action(async function Icon(req, res) {
5+
export default action(async function Icon({ req, res }) {
66
if (res.code || res.status || res.body) return;
77
const file = path.resolve(process.cwd(), 'icon.png');
88
if (fs.existsSync(file)) {

examples/with-entries/src/routes/login.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const template = `
1919
</html>
2020
`;
2121

22-
export default action(function Login(req, res) {
22+
export default action(function Login({ req, res }) {
2323
//send the response
2424
res.setHTML(template.trim());
2525
});
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { action } from '@stackpress/ingest';
22

3-
export default action(function Redirect(req, res) {
3+
export default action(function Redirect({ req, res }) {
44
res.redirect('/user');
55
});

examples/with-entries/src/routes/sse.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { action } from '@stackpress/ingest';
22

3-
export default action(async function SSE(req, res) {
3+
export default action(async function SSE({ req, res }) {
44
res.headers
55
.set('Cache-Control', 'no-cache')
66
.set('Content-Encoding', 'none')

0 commit comments

Comments
 (0)