-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved examples/thoughts to Wasp TS config. (#2337)
* Moved examples/thoughts to Wasp TS config. * fix
- Loading branch information
Showing
9 changed files
with
1,954 additions
and
2,504 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { App, ExtImport } from 'wasp-config' | ||
|
||
const app = new App('Thoughts', { | ||
title: 'Thoughts', | ||
wasp: { version: '^0.15.0' } | ||
}); | ||
|
||
app.db({ | ||
seeds: [{ import: 'devSeedBasic', from: '@src/server/seeds.js' }] | ||
}); | ||
|
||
app.auth({ | ||
userEntity: 'User', | ||
methods: { usernameAndPassword: {} }, | ||
onAuthFailedRedirectTo: '/login' | ||
}); | ||
|
||
appPageWithRoute('Main', '/', '@src/client/MainPage.jsx', { auth: true }); | ||
appPageWithRoute('Thoughts', '/thoughts', '@src/client/ThoughtsPage.jsx', { auth: true }); | ||
appPageWithRoute('Login', '/login', '@src/client/LoginPage.jsx'); | ||
appPageWithRoute('Signup', '/signup', '@src/client/SignupPage.jsx'); | ||
|
||
appAction('createThought', ['Thought', 'Tag'], '@src/server/actions.js'); | ||
appQuery( 'getTags', ['Tag'], '@src/server/queries.js'); | ||
appQuery( 'getThoughts', ['Thought'], '@src/server/queries.js'); | ||
|
||
function appPageWithRoute(pageName: string, path: string, from: ExtImport['from'], config?: { auth: boolean }) { | ||
const page = app.page(pageName, { | ||
component: { importDefault: pageName, from }, | ||
...(config?.auth && { authRequired: config?.auth }) | ||
}); | ||
app.route(pageName + 'Route', { path, to: page }); | ||
} | ||
|
||
function appQuery(jsName: string, entities: string[], from: ExtImport['from']) { | ||
app.query(jsName, { | ||
fn: { import: jsName, from }, | ||
entities | ||
}); | ||
} | ||
|
||
function appAction(jsName: string, entities: string[], from: ExtImport['from']) { | ||
app.action(jsName, { | ||
fn: { import: jsName, from }, | ||
entities | ||
}); | ||
} | ||
|
||
export default app; |
Oops, something went wrong.