Skip to content

Commit 8e79dbb

Browse files
committed
Finish expo notifications package
1 parent ae8ffa8 commit 8e79dbb

15 files changed

+83
-41
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nestjs-expo-notifications",
3-
"version": "0.0.1",
3+
"version": "0.1.8",
44
"description": "Expo notification module for nestjs",
55
"author": "Lukasz Lupa",
66
"private": false,
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { Inject } from '@nestjs/common';
2+
import { ExpoNotificationsDecorator } from '../interfaces';
3+
import { EXPO_NOTIFICATIONS_OPTIONS } from '../constants';
4+
5+
export function InjectExpoNotifications(): ExpoNotificationsDecorator {
6+
return Inject(EXPO_NOTIFICATIONS_OPTIONS);
7+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import {Expo, ExpoClientOptions} from 'expo-server-sdk';
2+
import {ExpoNotificationsClient} from '../interfaces';
3+
4+
/**
5+
*
6+
* @param options
7+
*/
8+
export function createClient(options?: ExpoClientOptions): ExpoNotificationsClient {
9+
return new Expo(options);
10+
}

src/common/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from './expo-notifications.utils';
2+
export * from './expo-notifications.decorator';
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const EXPO_NOTIFICATIONS_OPTIONS = 'EXPO_NOTIFICATIONS_OPTIONS';

src/constants/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './expo-notifications.constant';
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import {Global, DynamicModule, Module} from '@nestjs/common';
2+
import {ExpoClientOptions} from 'expo-server-sdk';
3+
import {createProviders} from './providers';
4+
5+
@Global()
6+
@Module({})
7+
export class ExpoNotificationsCoreModule {
8+
/**
9+
* Provides a dynamic module for your application.
10+
*
11+
* @param options - Expo SDK options
12+
* @param isGlobal - Whether this module should be globally imported, by default its true
13+
*/
14+
public static forRoot(options?: ExpoClientOptions, isGlobal = true): DynamicModule {
15+
const provider = createProviders(options);
16+
17+
return {
18+
exports: [provider],
19+
module: ExpoNotificationsCoreModule,
20+
providers: [provider],
21+
};
22+
}
23+
}

src/expo-notifications.module.ts

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,18 @@
1-
import {DynamicModule, Logger, Module, Provider} from '@nestjs/common';
1+
import {DynamicModule, Module} from '@nestjs/common';
22
import {ExpoClientOptions} from 'expo-server-sdk';
3-
import {ExpoNotificationsService} from "./expo-notifications.service";
3+
import {ExpoNotificationsCoreModule} from './expo-notifications-core.module';
44

55
@Module({})
66
export class ExpoNotificationsModule {
77
/**
88
* Provides a dynamic module for your application.
99
*
1010
* @param options - Expo SDK options
11-
* @param isGlobal - Whether this module should be globally imported, by default its true
1211
*/
13-
static forRoot(options?: ExpoClientOptions, isGlobal = true): DynamicModule {
14-
const providers: Provider[] = [
15-
{
16-
provide: ExpoNotificationsService,
17-
useValue: new ExpoNotificationsService(new Logger(), options),
18-
},
19-
];
20-
12+
public static forRoot(options?: ExpoClientOptions): DynamicModule {
2113
return {
22-
global: isGlobal,
2314
module: ExpoNotificationsModule,
24-
providers,
25-
exports: providers,
15+
imports: [ExpoNotificationsCoreModule.forRoot(options)],
2616
};
2717
}
2818
}

src/expo-notifications.service.ts

Lines changed: 0 additions & 26 deletions
This file was deleted.

src/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1+
export * from './constants';
2+
export * from './common';
3+
export * from './providers';
4+
export * from './interfaces';
15
export * from './expo-notifications.module';

0 commit comments

Comments
 (0)