mirror of
https://github.com/tiennm99/miti-google-play-scraper.git
synced 2026-04-17 17:21:26 +00:00
feat(core): convert to use module
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "miti-google-play-scraper",
|
"name": "miti-google-play-scraper",
|
||||||
"type": "commonjs",
|
"type": "module",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"express": "5.1.0",
|
"express": "5.1.0",
|
||||||
"google-play-scraper": "^10.1.0"
|
"google-play-scraper": "^10.1.0"
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
const express = require('express');
|
import express from 'express';
|
||||||
const gplay = require('google-play-scraper');
|
import gplay from 'google-play-scraper';
|
||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
|
|
||||||
app.use(express.json({ limit: '10mb' }));
|
app.use(express.json({ limit: '10mb' }));
|
||||||
@@ -7,7 +8,7 @@ app.use(express.json({ limit: '10mb' }));
|
|||||||
app.post('/scraper/:method', async (req, res) => {
|
app.post('/scraper/:method', async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const method = req.params.method;
|
const method = req.params.method;
|
||||||
const params = typeof req.body === 'string' ? JSON.parse(req.body) : req.body;
|
const params = req.body;
|
||||||
|
|
||||||
if (!gplay[method]) {
|
if (!gplay[method]) {
|
||||||
return res.status(400).json({
|
return res.status(400).json({
|
||||||
@@ -30,4 +31,4 @@ app.get('/', (req, res) => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
module.exports = app;
|
export default app;
|
||||||
Reference in New Issue
Block a user