Skip to content

Commit b07641a

Browse files
authored
Merge pull request #2 from Twirelab/feature/1
#1 - Update and clean code
2 parents be351e2 + ea60b64 commit b07641a

20 files changed

+2598
-17723
lines changed

.github/workflows/tests.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: "Test package"
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- "master"
7+
types:
8+
- "opened"
9+
- "synchronize"
10+
11+
jobs:
12+
test:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: "Checkout"
16+
uses: actions/checkout@v3
17+
- name: "Use Node.js"
18+
uses: actions/setup-node@v3
19+
with:
20+
node-version: 14
21+
cache: "npm"
22+
- name: "Install npm"
23+
run: npm ci
24+
- name: "Run all tests"
25+
run: npm run test

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# See http://help.github.com/ignore-files/ for more about ignoring files.
22

33
# compiled output
4-
/dist
54
/tmp
65
/out-tsc
6+
/lib
77

88
# dependencies
99
/node_modules

.prettierrc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
2-
"singleQuote": true,
3-
"trailingComma": "all",
2+
"singleQuote": false,
43
"semi": false
54
}

README.md

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,56 @@
1-
nestjs-expo-notifications
1+
# NestJS Expo Notifications [![Tests](https://github.com/Twirelab/nestjs-expo-notifications/actions/workflows/tests.yml/badge.svg)](https://github.com/Twirelab/nestjs-expo-notifications/actions/workflows/tests.yml)
2+
3+
Injectable Expo Notifications client for Nestjs
4+
5+
## Install
6+
7+
```bash
8+
npm i @twirelab/nestjs-expo-notifications expo-server-sdk
9+
```
10+
11+
or
12+
13+
```bash
14+
yarn add @twirelab/nestjs-expo-notifications expo-server-sdk
15+
```
16+
17+
## Usage
18+
19+
Add below code into app.module.js file.
20+
21+
```typescript
22+
import { ExpoNotificationsModule } from "@twirelab/nestjs-expo-notifications"
23+
24+
@Module({
25+
imports: [
26+
ExpoNotificationsModule.forRoot({
27+
// optionally providing an access token if you have enabled push security
28+
accessToken: "...",
29+
}),
30+
],
31+
})
32+
export class AppModule {}
33+
```
34+
35+
Now you can inject authentication client into your services, for example:
36+
37+
```typescript
38+
import { Injectable } from "@nestjs/common"
39+
import { InjectExpoNotifications } from "@twirelab/nestjs-expo-notifications"
40+
import { Expo } from "expo-server-sdk"
41+
42+
@Injectable()
43+
export class AppService {
44+
constructor(@InjectExpoNotifications() private readonly expo: Expo) {}
45+
46+
async sendNotifications(): Promise<TokenResponse> {
47+
return await this.expo.sendPushNotificationsAsync([
48+
{
49+
to: "ExponentPushToken[**********************]",
50+
title: "Testing notifications",
51+
body: "This is a testing notifications",
52+
},
53+
])
54+
}
55+
}
56+
```

jest.config.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
preset: "ts-jest",
3+
testEnvironment: "node",
4+
}

nest-cli.json

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

0 commit comments

Comments
 (0)