Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store past events #3

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
139 changes: 136 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,8 @@
"typescript": "^5.5.3",
"typescript-eslint": "^7.16.1",
"vitest": "^2.0.3"
},
"dependencies": {
"@supabase/supabase-js": "^2.45.1"
}
}
28 changes: 28 additions & 0 deletions src/secondary/CalendarPersistance.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { createClient } from '@supabase/supabase-js';
import { describe, it, expect } from 'vitest';

import { CalendarEvent } from '../domain/CalendarEvent';
import { Name } from '../domain/Name';

import { CalendarPersistance, Database } from './CalendarPersistance';

describe('CalendarPersistance', () => {
it('should save', async () => {
const client = createClient<Database>(process.env['SUPABASE_URL']!, process.env['SUPABASE_KEY']!);

Check failure on line 11 in src/secondary/CalendarPersistance.spec.ts

View workflow job for this annotation

GitHub Actions / build-pr

src/secondary/CalendarPersistance.spec.ts > CalendarPersistance > should save

Error: supabaseUrl is required. ❯ new SupabaseClient node_modules/@supabase/supabase-js/src/SupabaseClient.ts:75:29 ❯ Proxy.createClient node_modules/@supabase/supabase-js/src/index.ts:40:10 ❯ src/secondary/CalendarPersistance.spec.ts:11:20
const response = await client.from('events').insert({ id: 1 });
console.log(response);

const calendar = [
CalendarEvent.of({
id: 'id',
title: Name.of('Title'),
start: new Date('2024-01-01T00:00:00.000Z'),
end: new Date('2024-01-01T01:00:00.000Z'),
group: Name.of('group'),
}),
];
const calendarPeristance = new CalendarPersistance(client);

calendarPeristance.save(calendar);
});
});
27 changes: 27 additions & 0 deletions src/secondary/CalendarPersistance.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { SupabaseClient } from '@supabase/supabase-js';

import { Calendar } from '../domain/Calendar';

export interface Database {
public: {
Tables: {
events: {
Row: {
id: number;
};
Insert: {
id: number;
};
Update: {
id: number;
};
};
};
};
}

export class CalendarPersistance {
constructor(client: SupabaseClient<Database>) {}

save(calendar: Calendar) {}
}
Loading