Skip to content

Commit

Permalink
Merge pull request #2 from Twirelab/feature/1
Browse files Browse the repository at this point in the history
#1 - Update and clean code
  • Loading branch information
LukaszLupa authored Jun 1, 2024
2 parents be351e2 + ea60b64 commit b07641a
Show file tree
Hide file tree
Showing 20 changed files with 2,598 additions and 17,723 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: "Test package"

on:
pull_request:
branches:
- "master"
types:
- "opened"
- "synchronize"

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: "Checkout"
uses: actions/checkout@v3
- name: "Use Node.js"
uses: actions/setup-node@v3
with:
node-version: 14
cache: "npm"
- name: "Install npm"
run: npm ci
- name: "Run all tests"
run: npm run test
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.

# compiled output
/dist
/tmp
/out-tsc
/lib

# dependencies
/node_modules
Expand Down
3 changes: 1 addition & 2 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"singleQuote": true,
"trailingComma": "all",
"singleQuote": false,
"semi": false
}
57 changes: 56 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,56 @@
nestjs-expo-notifications
# 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)

Injectable Expo Notifications client for Nestjs

## Install

```bash
npm i @twirelab/nestjs-expo-notifications expo-server-sdk
```

or

```bash
yarn add @twirelab/nestjs-expo-notifications expo-server-sdk
```

## Usage

Add below code into app.module.js file.

```typescript
import { ExpoNotificationsModule } from "@twirelab/nestjs-expo-notifications"

@Module({
imports: [
ExpoNotificationsModule.forRoot({
// optionally providing an access token if you have enabled push security
accessToken: "...",
}),
],
})
export class AppModule {}
```

Now you can inject authentication client into your services, for example:

```typescript
import { Injectable } from "@nestjs/common"
import { InjectExpoNotifications } from "@twirelab/nestjs-expo-notifications"
import { Expo } from "expo-server-sdk"

@Injectable()
export class AppService {
constructor(@InjectExpoNotifications() private readonly expo: Expo) {}

async sendNotifications(): Promise<TokenResponse> {
return await this.expo.sendPushNotificationsAsync([
{
to: "ExponentPushToken[**********************]",
title: "Testing notifications",
body: "This is a testing notifications",
},
])
}
}
```
4 changes: 4 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
preset: "ts-jest",
testEnvironment: "node",
}
4 changes: 0 additions & 4 deletions nest-cli.json

This file was deleted.

Loading

0 comments on commit b07641a

Please sign in to comment.