Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue: 138 | Migrated project JS architecture to NestJS #143

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

Abhinav-Saxena-dev
Copy link

@Abhinav-Saxena-dev Abhinav-Saxena-dev commented Mar 30, 2024

#138

Description

  • Migrated the vanilla js architecture of the project to Nest js architecture, utilizing its benefits.

Project Structure

- src
  - app
    - models
      - city
        - city.controller.ts
        - city.module.ts
        - city.controller.spec.ts
        - city.service.ts
        - city.service.spec.ts
      - georev
        - georev.controller.ts
        - georev.module.ts
        - georev.serializer.ts
        - georev.controller.spec.ts
        - georev.service.ts
        - georev.service.spec.ts
      - location
        - location.controller.ts
        - location.module.ts
        - location.serializer.ts
        - location.controller.spec.ts
        - location.service.ts
        - location.service.spec.ts
  - config
    - config.ts
    - env
        - default.env
  - geojson-data
  - Scripts
    - gdb_to_geojson
    - parse.geojson
  - services
    - geojson
        - geojson.service.ts
        - geojson.service.spec.ts
    - geoquery
        - geoquery.service.ts
        - geoquery.service.spec.ts
  - util
    - serializer
      - success
      - error
  • Each module handles its respective endpoint.
  • GeoJson and GeoQuery services each contain common service functions having a single responsibility.
  • Formatting functions have been further classified as per their response status, if it's a success or an error. The serializer directory of utils contains these individual serializers.

Testing Screenshots

1. /city/{ip}

cURL: curl --location --request GET 'http://localhost:3000/city/2401:4900:1c82:377e:bb89:dfc9:28a1:1e06'

image

2. /city/batch

cURL: curl --location --request POST 'http://localhost:3000/city/batch' \ --header 'Content-Type: application/json' \ --data-raw '{ "ips": ["128.101.101.101", "2401:4900:1c82:377e:bb89:dfc9:28a1:1e06"] }'

image

3. /georev

cURL: curl --location --request GET 'http://localhost:3000/georev?lat=28.7041&lon=77.1025 ' \ --header 'Content-Type: application/json' \ --data-raw '{ "ips": ["128.101.101.101", "2401:4900:1c82:377e:bb89:dfc9:28a1:1e06"] }'

image

4. /location/{locationlevel}/centroid

cURL: curl --location --request GET 'http://localhost:3000/location/DISTRICT/centroid?query=lucknow'

image

5. /location/{locationlevel}/fuzzysearch

cURL: curl --location --request POST 'http://localhost:3000/location/VILLAGE/fuzzysearch' \ --header 'Content-Type: application/json' \ --data-raw '{ "query": "Arong", "filter": { "STATE": "Andaman & Nicobar Islands", "DISTRICT": "Nicobars" } }'

image

Tasks / Sequence of task completion

  • Setup structure of project
  • Configure project settings.
  • Identity and create modules
  • Classify each API endpoint and migrate code to respective modules.
  • Create common services
  • Implement utility files and functions.
  • Migrate script for initial setup.
  • Configure Swagger documentation.
  • Clean up logger usage
  • Code Clean up / Separate controller and business logic
  • Remove unnecessary boilerplate files.
  • Write test cases
  • Setup project documentation

@Abhinav-Saxena-dev Abhinav-Saxena-dev mentioned this pull request Mar 30, 2024
10 tasks
@Abhinav-Saxena-dev Abhinav-Saxena-dev marked this pull request as ready for review April 21, 2024 20:11
@ChakshuGautam
Copy link
Owner

Hey @Abhinav-Saxena-dev this is brilliant!!!

Give me a couple of days to review this. I was swamped earlier. Will start reviewing today onwards.

Copy link
Owner

@ChakshuGautam ChakshuGautam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make these change first before I review this further.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests need to be migrated too.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test cases have been updated

ChakshuGautam

This comment was marked as spam.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants