Pipriles
Pipriles
Explore posts from servers
NNuxt
Created by Pipriles on 7/31/2024 in #❓・help
Server middlewares issue
Hello everybody, I have a doubt regarding how server middlewares should work. I have a middleware located in server/middleware/auth.ts that throws an error when the users that sends the request is not authenticated... But it turns out that when I load any page that server middleware gets called. I thought those middlewares were only called on the api/server layer and didn't affect the nuxt pages initial load?
export default defineEventHandler((event) => {

const url = getRequestURL(event);

if (
url.pathname.startsWith('/api/connect') ||
url.pathname.startsWith('/connect') ||
url.pathname.startsWith('/api/auth')
) return console.log('[Skipping Auth]');

if (!isAuthenticated(event)) {
const message = `Access not allowed to ${url.pathname}`;
throw createError({ statusCode: 401, statusMessage: 'Unauthorized', message });
}

});
export default defineEventHandler((event) => {

const url = getRequestURL(event);

if (
url.pathname.startsWith('/api/connect') ||
url.pathname.startsWith('/connect') ||
url.pathname.startsWith('/api/auth')
) return console.log('[Skipping Auth]');

if (!isAuthenticated(event)) {
const message = `Access not allowed to ${url.pathname}`;
throw createError({ statusCode: 401, statusMessage: 'Unauthorized', message });
}

});
1 replies
DTDrizzle Team
Created by Pipriles on 7/11/2023 in #help
Use a different schema on postgres
Hello, I am currently trying to define a table with drizzle like this:
const rollupAccountResponsesDaily = pgTable('rollup_account_responses_daily', {
rollupDate: timestamp('rollup_date', { withTimezone: true }),
accountId: uuid('account_id'),
questionId: text('question_id'),
source: text('source'),
msa: text('msa'),
response: text('response'),
metrics: jsonb('metrics'),
createdAt: timestamp('created_at', { withTimezone: true }),
updatedAt: timestamp('updated_at', { withTimezone: true }),
});
const rollupAccountResponsesDaily = pgTable('rollup_account_responses_daily', {
rollupDate: timestamp('rollup_date', { withTimezone: true }),
accountId: uuid('account_id'),
questionId: text('question_id'),
source: text('source'),
msa: text('msa'),
response: text('response'),
metrics: jsonb('metrics'),
createdAt: timestamp('created_at', { withTimezone: true }),
updatedAt: timestamp('updated_at', { withTimezone: true }),
});
But this table is not on the public schema on postgres, is there a way to change the schema so that the generated code will be "sandbox.rollup_account_responses_daily" ? Thanks
2 replies