Skip to content

Commit

Permalink
Try non-actions
Browse files Browse the repository at this point in the history
  • Loading branch information
idan committed Jul 4, 2024
1 parent e4ac754 commit 444d794
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 20 deletions.
44 changes: 25 additions & 19 deletions src/routes/auth/+page.server.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,29 @@
import type { Actions } from './$types';
// // import type { Actions } from './$types';
// import { json } from '@sveltejs/kit';
// import type { RequestHandler } from './$types';
// // import { ApplicationInsights } from '@microsoft/applicationinsights-web'

import { ApplicationInsights } from '@microsoft/applicationinsights-web'
// // import { env } from '$env/dynamic/private';

import { env } from '$env/dynamic/private';
// // let appInsights: ApplicationInsights;
// // if ('APPLICATIONINSIGHTS_CONNECTION_STRING' in env) {
// // appInsights = new ApplicationInsights({ config: {
// // connectionString: env.APPLICATIONINSIGHTS_CONNECTION_STRING
// // } });
// // }

let appInsights: ApplicationInsights;
if ('APPLICATIONINSIGHTS_CONNECTION_STRING' in env) {
appInsights = new ApplicationInsights({ config: {
connectionString: env.APPLICATIONINSIGHTS_CONNECTION_STRING
} });
}

export const actions = {
login: async (event) => {
console.error("THE EVENT: ", event, event.request);
appInsights?.trackTrace({message: 'login event', properties: {event}});
return {action: 'login'};
},
logout: async (event) => {
return {action: 'logout'};
},
} satisfies Actions;
// // export const actions = {
// // login: async (event) => {
// // console.error("THE EVENT: ", event, event.request);
// // appInsights?.trackTrace({message: 'login event', properties: {event}});
// // return {action: 'login'};
// // },
// // logout: async (event) => {
// // return {action: 'logout'};
// // },
// // } satisfies Actions;

// export const fallback: RequestHandler = async ({request}) => {
// return json(request);
// }
3 changes: 2 additions & 1 deletion src/routes/auth/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
export let form: ActionData;
</script>

<div>Form action: {form?.action}</div>
<!-- <div>Form action: {form?.action}</div> -->
<div>Form action: nada</div>
6 changes: 6 additions & 0 deletions src/routes/auth/+server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { json } from '@sveltejs/kit';
import type { RequestHandler } from './$types';

export const fallback: RequestHandler = async ({request, platform}) => {
return json({request, platform});
}

0 comments on commit 444d794

Please sign in to comment.