Browse Source

Move to self-hosted Gitea, update dependencies, rename some files.

tags/2.2.3^0
Bauke 1 year ago
parent
commit
04dfe00f79
Signed by: Bauke <me@bauke.xyz> GPG Key ID: C1C0F29952BCF558
9 changed files with 453 additions and 1302 deletions
  1. +0
    -29
      .gitlab-ci.yml
  2. +0
    -17
      .nycrc.json
  3. +2
    -2
      LICENSE
  4. +8
    -29
      README.md
  5. +18
    -15
      package.json
  6. +3
    -0
      source/index.ts
  7. +1
    -1
      tests/index.test.ts
  8. +4
    -2
      tsconfig.json
  9. +417
    -1207
      yarn.lock

+ 0
- 29
.gitlab-ci.yml View File

@@ -1,29 +0,0 @@
.common:
image: alekzonder/puppeteer
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- node_modules/
before_script:
- node --version
- yarn --version
- yarn

test:
extends: .common
stage: test
script:
- yarn test
artifacts:
paths:
- coverage/lcov.info

codecov:
extends: .common
stage: deploy
only:
- master@Bauke/node-ddg
script:
- yarn codecov
dependencies:
- test

+ 0
- 17
.nycrc.json View File

@@ -1,17 +0,0 @@
{
"all": true,
"extension": [
".ts"
],
"include": [
"source/**"
],
"reporter": [
"html",
"lcov",
"text"
],
"require": [
"ts-node/register"
]
}

+ 2
- 2
LICENSE View File

@@ -1,6 +1,6 @@
MIT License
The MIT License

Copyright (c) 2019 Bauke <me@bauke.xyz>
Copyright (c) 2019-2020 Bauke <me@bauke.xyz>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal


+ 8
- 29
README.md View File

@@ -2,43 +2,22 @@

> Get DuckDuckGo results in Node.

[![npm version](https://img.shields.io/npm/v/node-ddg?color=blue&style=flat-square)](https://npmjs.com/package/node-ddg)
[![npm downloads per month](https://img.shields.io/npm/dm/node-ddg?color=blue&style=flat-square)](https://npmjs.com/package/node-ddg)
[![npm license](https://img.shields.io/npm/l/node-ddg?color=blue&style=flat-square)](https://npmjs.com/package/node-ddg)

## Usage

```typescript
import {search, Result} from 'node-ddg';

search({query: 'duckduckgo', maxResults: 3})
.then((results: Result[]) => { ... })
.catch((error: Error) => { ... });
.then((results: Result[]) => console.log(results))
.catch(console.error);
```

## Documentation

### search

> Returns the title, body and link of searched queries from DuckDuckGo.

`search(SearchOptions): Promise<Result[]>;`

#### Result

- `body: string` The body of the result: the website's description.
- `title: string` The title of the result: the website's title.
- `link: string` The link of the result: the link to the website.

#### SearchOptions

- `maxResults: number` The maximum amount of results to return, defaults to `5`. (Optional)
- **`query: string` The query you're searching for. (Required)**
- `safeSearch: SafeSearchEnum` The Safe Search mode you want, defaults to `MODERATE`. See https://duckduckgo.com/params or below for values. (Optional)
- `secure: boolean` Whether to use HTTP or HTTPS, defaults to `true`. (Optional)

#### SafeSearchEnum

- `OFF` = `-2`
- `MODERATE` = `-1`
- `ON` = ` 1`
For more examples, see [the source](https://git.holllo.cc/Bauke/node-ddg/src/branch/main/source/index.ts) and [test files](https://git.holllo.cc/Bauke/node-ddg/src/branch/main/tests/index.test.ts).

## License

Licensed under [MIT](License).
Open-sourced with the [MIT License](https://git.holllo.cc/Bauke/node-ddg/src/branch/main/LICENSE).

+ 18
- 15
package.json View File

@@ -1,32 +1,32 @@
{
"name": "node-ddg",
"version": "2.2.2",
"description": "Get DuckDuckGo results in Node.",
"version": "2.2.3",
"author": "Bauke <me@bauke.xyz>",
"repository": "https://gitlab.com/Bauke/node-ddg",
"homepage": "https://git.holllo.cc/Bauke/node-ddg",
"license": "MIT",
"main": "build/source/main.js",
"types": "build/source/main.d.ts",
"main": "build/source/index.js",
"types": "build/source/index.d.ts",
"files": [
"build/source/"
],
"scripts": {
"build": "tsc",
"test": "xo && nyc ava -v --serial"
"test": "xo && ava --verbose --serial",
"prepublishOnly": "rm -rf build/ && yarn build && yarn test"
},
"dependencies": {
"cheerio": "^1.0.0-rc.2",
"puppeteer": "^5.0.0",
"puppeteer": "^5.2.1",
"query-string": "^6.13.1"
},
"devDependencies": {
"@types/cheerio": "^0.22.21",
"@types/node": "^14.0.20",
"@types/puppeteer": "^3.0.1",
"ava": "^3.10.1",
"codecov": "^3.7.0",
"nyc": "^15.1.0",
"ava": "^3.11.0",
"husky": "^4.2.5",
"ts-node": "^8.10.2",
"typescript": "^3.9.6",
"typescript": "^3.9.7",
"xo": "^0.32.1"
},
"keywords": [
@@ -38,17 +38,20 @@
"ts"
],
"files": [
"test/**/*.test.ts"
"tests/*.test.ts"
],
"require": [
"ts-node/register"
]
},
"xo": {
"ignores": [
"build/**"
],
"prettier": true,
"space": true
},
"husky": {
"hooks": {
"pre-commit": "yarn test",
"pre-push": "yarn test"
}
}
}

source/main.ts → source/index.ts View File

@@ -9,8 +9,11 @@ export enum SafeSearchEnum {
}

export interface Result {
// The body of the result, the website's description.
body: string;
// The title of the result, the website's title.
title: string;
// The link of the result, the link to the website.
url: string;
}


test/main.test.ts → tests/index.test.ts View File

@@ -1,5 +1,5 @@
import test, {ExecutionContext} from 'ava';
import {Result, SafeSearchEnum, search} from '../source/main';
import {Result, SafeSearchEnum, search} from '../source';

test('Searching for "duckduckgo" should return result', async (t: ExecutionContext) => {
t.plan(4);

+ 4
- 2
tsconfig.json View File

@@ -4,14 +4,16 @@
"esModuleInterop": true,
"module": "commonjs",
"outDir": "build/",
"sourceMap": true,
"strict": true,
"target": "es2017"
},
"include": [
"source/*.ts",
"test/*.test.ts"
"tests/*.ts"
],
"exclude": [
"node_modules"
"node_modules/",
"build/"
]
}

+ 417
- 1207
yarn.lock
File diff suppressed because it is too large
View File


Loading…
Cancel
Save