Skip to content

Commit

Permalink
chore: use ts for src
Browse files Browse the repository at this point in the history
  • Loading branch information
blasdfaa committed Nov 10, 2024
1 parent d5bc11c commit 0e00896
Show file tree
Hide file tree
Showing 27 changed files with 5,946 additions and 423 deletions.
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
charset = utf-8

[*.js]
indent_style = space
indent_size = 2

[{package.json,*.yml,*.cjson}]
indent_style = space
indent_size = 2
57 changes: 44 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,58 @@
name: CI workflow

on:
push:
pull_request:
branches:
- main
pull_request:
push:
branches:
- main
- renovate/*

jobs:
lint:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- run: corepack enable
- uses: actions/setup-node@v4
with:
node-version: lts/*
cache: pnpm

- name: 📦 Install dependencies
run: pnpm install --frozen-lockfile

- name: 🔠 Lint project
run: pnpm lint

test:
runs-on: ${{ matrix.os }}

strategy:
matrix:
node-version: [10.x, 12.x, 14.x]
os: [ubuntu-latest, windows-latest]
node: [lts/*]
os: [ubuntu-latest, windows-latest, macos-latest]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Install Dependencies
run: npm install --ignore-scripts
- name: Test
run: npm run test
- uses: actions/checkout@v4
- run: corepack enable

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: pnpm

- name: 📦 Install dependencies
run: pnpm install --frozen-lockfile

- name: 🛠 Build project
run: pnpm build

- name: 🧪 Test project
run: pnpm test

- name: 🟩 Coverage
uses: codecov/codecov-action@v4
26 changes: 26 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: release

permissions:
contents: write

on:
push:
tags:
- 'v*'

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set node
uses: actions/setup-node@v4
with:
node-version: 20

- run: npx changelogithub
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
159 changes: 6 additions & 153 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,155 +1,8 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional stylelint cache
.stylelintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# vuepress v2.x temp and cache directory
.temp
.cache

# Docusaurus cache and generated files
.docusaurus

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

# Vim swap files
*.swp

# macOS files
.DS_Store

# Clinic
.clinic

# lock files
bun.lockb
package-lock.json
pnpm-lock.yaml
yarn.lock

# editor files
node_modules
coverage
.vscode
.idea

#tap files
.tap/

# test tap report
out.tap
.DS_Store
.eslintcache
*.log*
*.env*
1 change: 0 additions & 1 deletion .npmrc

This file was deleted.

5 changes: 0 additions & 5 deletions .taprc

This file was deleted.

40 changes: 35 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# fastify-grammy

![CI](https://github.com/blasdfaa/fastify-grammy/workflows/CI/badge.svg)
[![CI](https://github.com/blasdfaa/fastify-grammy/workflows/CI/badge.svg)](https://github.com/blasdfaa/fastify-grammy/actions/workflows/ci.yml)
[![NPM version](https://img.shields.io/npm/v/fastify-grammy.svg?style=flat)](https://www.npmjs.com/package/fastify-grammy)

## 🚧 In development
Expand All @@ -12,23 +12,53 @@ Supports Fastify versions `5.x`
## Install

```
npm i fastify-grammy
# npm
npm install fastify-grammy
# pnpm
pnpm install fastify-grammy
```

## Usage

Require `fastify-grammy` and register.
Import `fastify-grammy` and register.

```js
const fastify = require('fastify')()
import Fastify from 'fastify'
import { fastifyGrammy } from 'fastify-grammy'

const fastify = Fastify()

fastify.register(require('fastify-grammy'), {
fastify.register(fastifyGrammy, {
token: 'your-tg-bot-token'
})

fastify.listen({ port: 3000 })
```

## Using with TypeScript

```ts
import type { FastifyGrammyBot } from 'fastify-grammy'

// for single instance
declare module 'fastify' {
interface FastifyInstance {
grammy: FastifyGrammyBot
}
}

// for multiple instances
declare module 'fastify' {
interface FastifyInstance {
grammy: {
one: FastifyGrammyBot
two: FastifyGrammyBot
}
}
}
```

## Acknowledgements

## License
Expand Down
12 changes: 12 additions & 0 deletions build.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { defineBuildConfig } from 'unbuild'

export default defineBuildConfig({
entries: [
'src/index',
],
declaration: true,
clean: true,
rollup: {
emitCJS: true,
},
})
20 changes: 0 additions & 20 deletions errors.js

This file was deleted.

3 changes: 3 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import antfu from '@antfu/eslint-config'

export default antfu()
Loading

0 comments on commit 0e00896

Please sign in to comment.