Skip to content

Commit 362a92c

Browse files
committed
chore: wip
1 parent 74c232e commit 362a92c

File tree

4 files changed

+19
-3
lines changed

4 files changed

+19
-3
lines changed

.github/workflows/ci.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ jobs:
128128
run: |
129129
echo "CONTAINS_RELEASE=$(git log --format=%B -n 1 ${{ github.event.after }} | grep -ci 'release')" >> $GITHUB_ENV
130130
echo "contains_release=${{ env.CONTAINS_RELEASE }}" >> $GITHUB_OUTPUT
131+
131132
deploy-prod:
132133
if: github.ref == 'refs/heads/main' && github.event_name == 'push' && needs.check_commit_message.outputs.contains_release == '0'
133134
needs: [lint, typecheck, test]
@@ -152,7 +153,15 @@ jobs:
152153
- name: Install Dependencies
153154
run: bun install
154155

156+
# set the .env file
157+
- name: Ensure .env Set
158+
run: |
159+
cp .env.example .env
160+
155161
- name: Deploy
162+
env:
163+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
164+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
156165
run: bun buddy deploy production
157166

158167
deploy-stage:

app/Jobs/ExampleJob.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ export default new Job({
99
backoff: 3, // optional, defaults to 3-second delays between retries
1010
rate: Every.Minute, // optional, '* * * * *' in cron syntax (overwrites the Scheduler's definition)
1111
handle: () => { // action: 'SendWelcomeEmail', // instead of handle, you may target an action or `action: () => {`
12-
log.info('This cron job log this message every minute')
12+
log.info('This message logs every minute') // unless triggered via a route.job() call, in which case it logs once
1313
},
1414
})

routes/api.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ route.get('/api/welcome/', () => 'hello world 4') // stacksjs.org/api/welcome/
99
route.health() // /api/health
1010
route.get('/api/buddy/commands', 'Buddy/CommandsAction')
1111
route.get('/api/buddy/versions', 'Buddy/VersionsAction')
12-
// route.job('/api/example') // the equivalent of route.get('/api/example', 'ExampleJob')
12+
route.job('/api/example') // the equivalent of route.get('/api/example', 'ExampleJob')
13+
// route.action('/api/buddy') // the equivalent of route.get('/api/buddy', 'BuddyAction')
1314
// route.get('/api/buddy-2', '../app/Actions/BuddyAction') // todo: support this
1415
// route.get('/api/buddy-3', import('../app/Actions/BuddyAction')) // todo: support this
1516

storage/framework/core/router/src/router.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { RedirectCode, Route, RouteGroupOptions, StatusCode } from '@stacksjs/types'
22
import { path as p, projectPath } from '@stacksjs/path'
3+
import { pascalCase } from '@stacksjs/strings'
34

45
export interface RouterInterface {
56
get: (url: Route['url'], callback: Route['callback']) => Promise<this>
@@ -52,6 +53,7 @@ export class Router implements RouterInterface {
5253
const actionModule = await callback
5354
callback = actionModule.default
5455
}
56+
5557
else if (typeof callback === 'string') {
5658
// import the module and use the default.handle function as the callback
5759
const actionModule = await import(p.userActionsPath(`${callback}.ts`))
@@ -73,7 +75,11 @@ export class Router implements RouterInterface {
7375
}
7476

7577
public async job(path: Route['url']): Promise<this> {
76-
const jobModule = await import(p.userJobsPath('ExampleJob.ts'))
78+
if (path.includes('api/')) // TODO: once the api prefix is removed from the router/api, remove this
79+
pascalCase(path.replace(/^api\/?|^\//, ''))
80+
81+
// removes the potential `JobJob` suffix in case the user does not choose to use the Job suffix in their file name
82+
const jobModule = await import(p.userJobsPath(`${path}Job.ts`.replace(/JobJob/, 'Job')))
7783
const callback = jobModule.default.handle
7884

7985
this.addRoute('GET', path, callback, 200)

0 commit comments

Comments
 (0)