atlas-obscura-api 3.1.1 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { Coordinates, FetchOptions } from './interfaces/global';
2
- import { LocationResult } from './interfaces/locations.interface';
3
- import { Place, PlaceShort } from './interfaces/placeId.interface';
4
- import { PlacesAll } from './interfaces/places-all.interface';
5
- import { PlacesScraper } from './services/location.service';
1
+ import { Coordinates, FetchOptions } from './interfaces/global.js';
2
+ import { LocationResult } from './interfaces/locations.interface.js';
3
+ import { Place, PlaceShort } from './interfaces/placeId.interface.js';
4
+ import { PlacesAll } from './interfaces/places-all.interface.js';
5
+ import { PlacesScraper } from './services/location.service.js';
6
6
  export declare class AtlasObscura {
7
7
  private locationService;
8
8
  constructor(locationService: PlacesScraper);
package/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.atlasobscura = exports.AtlasObscura = void 0;
4
- const location_service_1 = require("./services/location.service");
4
+ const location_service_js_1 = require("./services/location.service.js");
5
5
  class AtlasObscura {
6
6
  locationService;
7
7
  constructor(locationService) {
@@ -23,5 +23,5 @@ class AtlasObscura {
23
23
  }
24
24
  }
25
25
  exports.AtlasObscura = AtlasObscura;
26
- const locationScraper = new location_service_1.PlacesScraper();
26
+ const locationScraper = new location_service_js_1.PlacesScraper();
27
27
  exports.atlasobscura = new AtlasObscura(locationScraper);
@@ -1,4 +1,4 @@
1
- import { Coordinates } from './global';
1
+ import { Coordinates } from './global.js';
2
2
  export interface LocationResult {
3
3
  total: Total;
4
4
  per_page: number;
@@ -1,4 +1,4 @@
1
- import { Coordinates } from './global';
1
+ import { Coordinates } from './global.js';
2
2
  export interface PlaceShort {
3
3
  id: number;
4
4
  title: string;
@@ -1,4 +1,4 @@
1
- import { Coordinates } from './global';
1
+ import { Coordinates } from './global.js';
2
2
  export interface PlacesAll extends Coordinates {
3
3
  id: number;
4
4
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "atlas-obscura-api",
3
- "version": "3.1.1",
3
+ "version": "3.2.0",
4
4
  "description": "Atlas Obscura API in JavaScript. NPM library for scrapping atlasobscura.com",
5
5
  "main": "./index.js",
6
6
  "author": "BART! <bart@bartweb.cz>",
@@ -22,7 +22,7 @@
22
22
  "release:major": "git checkout master && npm version major -m \"chore(update): major release %s 💥\""
23
23
  },
24
24
  "dependencies": {
25
- "cross-fetch": "^4.0.0",
25
+ "cross-fetch": "^4.1.0",
26
26
  "node-html-parser": "^7.0.1"
27
27
  },
28
28
  "repository": {
@@ -1,7 +1,7 @@
1
- import { Coordinates, FetchOptions } from './../interfaces/global';
2
- import { LocationResult } from './../interfaces/locations.interface';
3
- import { PlaceExtend, PlaceShort } from './../interfaces/placeId.interface';
4
- import { PlacesAll } from './../interfaces/places-all.interface';
1
+ import { Coordinates, FetchOptions } from './../interfaces/global.js';
2
+ import { LocationResult } from './../interfaces/locations.interface.js';
3
+ import { PlaceExtend, PlaceShort } from './../interfaces/placeId.interface.js';
4
+ import { PlacesAll } from './../interfaces/places-all.interface.js';
5
5
  export declare class PlacesScraper {
6
6
  placesAll(options?: FetchOptions): Promise<PlacesAll[]>;
7
7
  search(coords: Coordinates, page?: number, options?: FetchOptions): Promise<LocationResult>;
@@ -2,26 +2,26 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PlacesScraper = void 0;
4
4
  const node_html_parser_1 = require("node-html-parser");
5
- const fetchers_1 = require("../fetchers");
6
- const utils_1 = require("../utils");
7
- const vars_1 = require("../vars");
5
+ const index_js_1 = require("../fetchers/index.js");
6
+ const utils_js_1 = require("../utils.js");
7
+ const vars_js_1 = require("../vars.js");
8
8
  class PlacesScraper {
9
9
  async placesAll(options) {
10
- const response = await (0, fetchers_1.fetchPage)(vars_1.URL_PLACES_ALL, options?.headers);
10
+ const response = await (0, index_js_1.fetchPage)(vars_js_1.URL_PLACES_ALL, options?.headers);
11
11
  const html = (0, node_html_parser_1.parse)(response).innerHTML;
12
12
  const data = html.match(/AtlasObscura\.all_places = (.*?);/);
13
- return (0, utils_1.parseResults)(data);
13
+ return (0, utils_js_1.parseResults)(data);
14
14
  }
15
15
  async search(coords, page = 1, options) {
16
- const url = (0, vars_1.urlSearch)(coords, page);
17
- const response = await (0, fetchers_1.fetchPage)(url, options?.headers);
16
+ const url = (0, vars_js_1.urlSearch)(coords, page);
17
+ const response = await (0, index_js_1.fetchPage)(url, options?.headers);
18
18
  const html = (0, node_html_parser_1.parse)(response).innerHTML;
19
19
  const data = html.match(/AtlasObscura\.place_search = (.*?);/);
20
- return (0, utils_1.parseResults)(data);
20
+ return (0, utils_js_1.parseResults)(data);
21
21
  }
22
22
  async placeByIdShort(id, options) {
23
- const url = (0, vars_1.urlPlaceId)(id);
24
- const data = await (0, fetchers_1.fetchPage)(url, options?.headers);
23
+ const url = (0, vars_js_1.urlPlaceId)(id);
24
+ const data = await (0, index_js_1.fetchPage)(url, options?.headers);
25
25
  let place = null;
26
26
  try {
27
27
  place = JSON.parse(data);
@@ -35,7 +35,7 @@ class PlacesScraper {
35
35
  return place;
36
36
  }
37
37
  async placeFull(url, options) {
38
- const data = await (0, fetchers_1.fetchPage)(url, options?.headers);
38
+ const data = await (0, index_js_1.fetchPage)(url, options?.headers);
39
39
  const html = (0, node_html_parser_1.parse)(data);
40
40
  const descriptions = html.querySelectorAll('.place-body p').map((p) => p.innerHTML);
41
41
  const sectionDirections = Array.from(html.querySelectorAll('section')).find((sec) => {