Skip to content

Commit 75303cf

Browse files
authored
Merge pull request #4 from Adrianmjim/chore/add-readme
chore(docs): Add README
2 parents 5426617 + 5585cd5 commit 75303cf

File tree

5 files changed

+256
-10
lines changed

5 files changed

+256
-10
lines changed

.github/workflows/codecov_test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Codecov test main
1+
name: Test
22

33
on:
44
push:

.github/workflows/create_release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
git config --global user.name "${{ github.event.sender.login }}"
3636
3737
- name: Apply standard-version
38-
run: standard-version -t "" --no-verify
38+
run: standard-version -t "" --no-verify --first-release
3939

4040
- name: Get new version
4141
id: version

README.md

Lines changed: 236 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,236 @@
1+
<p align="center" style="vertical-align:middle">
2+
<a href="https://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo_text.svg" width="200" alt="Nest Logo" /></a><br /><a href="https://supabase.com/" target="blank"><img src="https://user-images.githubusercontent.com/8291514/213727225-56186826-bee8-43b5-9b15-86e839d89393.png#gh-dark-mode-only" width="500" alt="Supabase"></a>
3+
</p>
4+
5+
![Test](https://github.com/adrianmjim/nestjs-supabase-js/actions/workflows/codecov_test.yml/badge.svg)
6+
[![codecov](https://codecov.io/gh/Adrianmjim/nestjs-supabase-js/graph/badge.svg?token=jNHEDepqm7)](https://codecov.io/gh/Adrianmjim/nestjs-supabase-js)
7+
[![NPM Version](https://badge.fury.io/js/nestjs-supabase-js.svg?style=flat)](https://npmjs.org/package/nestjs-supabase-js)
8+
[![NPM Download Stats](https://nodei.co/npm/nestjs-supabase-js.png?downloads=true)](https://www.npmjs.com/package/nestjs-supabase-js)
9+
10+
## Description
11+
12+
The [Supabase](https://github.com/supabase/supabase-js) module for [NestJS](https://github.com/nestjs/nest).
13+
14+
## Installation
15+
16+
First install the dependencies via `npm`, `pnpm` or `yarn`:
17+
18+
npm:
19+
```bash
20+
$ npm i -s @nest/common @supabase/supabase-js nest-supabase-js
21+
```
22+
23+
pnpm:
24+
```bash
25+
$ pnpm add @nest/common @supabase/supabase-js nest-supabase-js
26+
```
27+
28+
yarn:
29+
```bash
30+
$ yarn add @nest/common @supabase/supabase-js nest-supabase-js
31+
```
32+
33+
## Configuration
34+
35+
First, import the module into your NestJS application and configure it using the configuration key provided by Supabase.
36+
37+
```typescript
38+
import { Module } from '@nestjs/common';
39+
import { SupabaseModule } from 'nestjs-supabase-js';
40+
41+
@Module({
42+
imports: [
43+
SupabaseModule.forRoot({
44+
supabaseKey: 'YOUR_SUPABASE_KEY',
45+
supabaseUrl: 'YOUR_SUPABASE_URL',
46+
}),
47+
],
48+
})
49+
export class AppModule {}
50+
```
51+
52+
Or, You can configure it asynchronously as follows:
53+
54+
```typescript
55+
import { Module } from '@nestjs/common';
56+
import { SupabaseModule } from 'nestjs-supabase-js';
57+
58+
@Module({
59+
imports: [
60+
SupabaseModule.forRootAsync({
61+
imports: [],
62+
inject: [],
63+
useFactory: () => ({
64+
supabaseKey: 'YOUR_SUPABASE_KEY',
65+
supabaseUrl: 'YOUR_SUPABASE_URL',
66+
}),
67+
}),
68+
],
69+
})
70+
export class AppModule {}
71+
```
72+
73+
## Multiple connections
74+
75+
In certain situations, we will need to connect to different Supabase projects, with this module this is possible:
76+
77+
```typescript
78+
import { Module } from '@nestjs/common';
79+
import { SupabaseModule } from 'nestjs-supabase-js';
80+
81+
@Module({
82+
imports: [
83+
SupabaseModule.forRoot([
84+
{
85+
name: 'connection1',
86+
supabaseConfig: {
87+
supabaseKey: 'YOUR_SUPABASE_KEY',
88+
supabaseUrl: 'YOUR_SUPABASE_URL',
89+
},
90+
},
91+
{
92+
name: 'connection2',
93+
supabaseConfig: {
94+
supabaseKey: 'YOUR_SUPABASE_KEY',
95+
supabaseUrl: 'YOUR_SUPABASE_URL',
96+
},
97+
},
98+
]),
99+
],
100+
})
101+
export class AppModule {}
102+
```
103+
104+
Or asynchronously:
105+
106+
```typescript
107+
import { Module } from '@nestjs/common';
108+
import { SupabaseModule } from 'nestjs-supabase-js';
109+
110+
@Module({
111+
imports: [
112+
SupabaseModule.forRootAsync({
113+
imports: [],
114+
inject: [],
115+
useFactory: () => ([
116+
{
117+
name: 'connection1',
118+
supabaseConfig: {
119+
supabaseKey: 'YOUR_SUPABASE_KEY',
120+
supabaseUrl: 'YOUR_SUPABASE_URL',
121+
},
122+
},
123+
{
124+
name: 'connection2',
125+
supabaseConfig: {
126+
supabaseKey: 'YOUR_SUPABASE_KEY',
127+
supabaseUrl: 'YOUR_SUPABASE_URL',
128+
},
129+
},
130+
]),
131+
}),
132+
],
133+
})
134+
export class AppModule {}
135+
```
136+
137+
## Usage
138+
139+
First, inject the client into the module where you want to use it:
140+
141+
```typescript
142+
import { Module } from '@nestjs/common';
143+
import { SupabaseModule } from 'nestjs-supabase-js';
144+
145+
@Module({
146+
imports: [
147+
SupabaseModule.injectClient(),
148+
],
149+
})
150+
export class CatModule {}
151+
```
152+
153+
Or, for a specific connection:
154+
155+
```typescript
156+
import { Module } from '@nestjs/common';
157+
import { SupabaseModule } from 'nestjs-supabase-js';
158+
159+
@Module({
160+
imports: [
161+
SupabaseModule.injectClient('connection1', 'connection2'),
162+
],
163+
})
164+
export class CatModule {}
165+
```
166+
167+
Now you can use the Supabase client in any provider of your module:
168+
169+
```typescript
170+
import { SupabaseClient } from '@supabase/supabase-js';
171+
172+
export class CatService {
173+
constructor(private readonly supabaseClient: SupabaseClient) {}
174+
175+
public doSomething(): void {
176+
177+
}
178+
}
179+
```
180+
181+
Or, for a specific connection:
182+
183+
```typescript
184+
import { SupabaseClient } from '@supabase/supabase-js';
185+
import { InjectSupabaseClient } from 'nestjs-supabase-js';
186+
187+
export class CatService {
188+
constructor(
189+
@InjectSupabaseClient('connection1') private readonly supabaseClient1: SupabaseClient,
190+
@InjectSupabaseClient('connection2') private readonly supabaseClient2: SupabaseClient,
191+
) {}
192+
193+
public doSomething(): void {
194+
195+
}
196+
}
197+
```
198+
199+
It's also possible to use the InjectSupabaseClient decorator to inject the Supabase client when you don't want to explicitly type it with the client:
200+
201+
```typescript
202+
import { SupabaseClient } from '@supabase/supabase-js';
203+
import { InjectSupabaseClient } from 'nestjs-supabase-js';
204+
205+
export class CatService {
206+
constructor(
207+
@InjectSupabaseClient() private readonly supabaseClient: unknown,
208+
) {}
209+
210+
public doSomething(): void {
211+
212+
}
213+
}
214+
```
215+
216+
## 🤝 Contributing [![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/adrianmjim/nestjs-supabase-js/issues)
217+
218+
Contributions, issues and feature requests are welcome.
219+
220+
## Authors
221+
222+
👤 **Adrián Martínez Jiménez**
223+
224+
- Github: [@adrianmjim](https://github.com/adrianmjim)
225+
226+
See also the list of contributors who [participated](https://github.com/adrianmjim/nestjs-supabase-js/contributors) in this project.
227+
228+
## Show Your Support
229+
230+
Please ⭐️ this repository if this project helped you!
231+
232+
## 📝 License
233+
234+
Copyright © 2024 [Adrián Martínez Jiménez](https://github.com/adrianmjim).
235+
236+
This project is licensed under the MIT License - see the [LICENSE file](LICENSE) for details.

package.json

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,32 @@
11
{
2-
"name": "nestjs-supabase",
3-
"version": "0.0.1",
4-
"description": "meow meow meow",
2+
"name": "nestjs-supabase-js",
3+
"version": "1.0.0",
4+
"description": "NestJS Supabase integration",
55
"keywords": [
66
"nestjs",
77
"supabase",
8-
"module"
8+
"supabase-js",
9+
"module",
10+
"supabase-auth",
11+
"supabase-db",
12+
"database",
13+
"auth",
14+
"authentication",
15+
"postgres",
16+
"supabase-storage",
17+
"supabase-realtime",
18+
"storage"
919
],
1020
"author": "Adrián Martínez Jiménez <adrianmjim199434@gmail.com>",
11-
"homepage": "https://github.com/adrianmjim/nestjs-supabase#readme",
21+
"homepage": "https://github.com/adrianmjim/nestjs-supabase-js#readme",
1222
"license": "ISC",
1323
"main": "lib/index.js",
1424
"repository": {
1525
"type": "git",
16-
"url": "git+https://github.com/adrianmjim/nestjs-supabase.git"
26+
"url": "git+https://github.com/adrianmjim/nestjs-supabase-js.git"
1727
},
1828
"bugs": {
19-
"url": "https://github.com/adrianmjim/nestjs-supabase/issues"
29+
"url": "https://github.com/adrianmjim/nestjs-supabase-js/issues"
2030
},
2131
"devDependencies": {
2232
"@jest/globals": "29.7.0",

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ export { NestSupabaseConfigFactory } from './models/NestSupabaseConfigFactory';
66
export { NestSupabaseConfigFactoryAsyncOptions } from './models/NestSupabaseConfigFactoryAsyncOptions';
77
export { NameSupabaseConfigPair } from './models/NameSupabaseConfigPair';
88
export { SupabaseConfig } from './models/SupabaseConfig';
9-
export { SupabaseModule } from './modules/SupabaseModule';
9+
export { SupabaseModule } from './modules/SupabaseModule';

0 commit comments

Comments
 (0)