Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions app.js → app.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
const express = require('express')
const helmet = require('helmet')
const cors = require('cors')
const morgan = require('morgan')
import express from 'express'
import helmet from 'helmet'
import cors from 'cors'
import morgan from 'morgan'
import api from './src/api'

const app = express()

Expand Down Expand Up @@ -44,8 +45,8 @@ app.use(

app.use(express.json())

const api = require('./src/api')

app.use(api)

export default app
// support CommonJS default import
module.exports = app
10 changes: 5 additions & 5 deletions index.js → index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable no-console */
const http = require('http')
const app = require('./app')
import http from 'http'
import app from './app'

/**
* Create HTTP server.
Expand All @@ -10,7 +10,7 @@ const server = http.createServer(app)
/**
* Normalize a port into a number, string, or false.
*/
const normalizePort = (val) => {
const normalizePort = (val: string): number | string | false => {
const numericPort = parseInt(val, 10)

// eslint-disable-next-line no-restricted-globals
Expand All @@ -36,7 +36,7 @@ app.set('port', port)
/**
* Event listener for HTTP server "error" event.
*/
const onError = (error) => {
const onError = (error: NodeJS.ErrnoException) => {
if (error.syscall !== 'listen') {
throw error
}
Expand All @@ -63,7 +63,7 @@ const onError = (error) => {
*/
const onListening = () => {
const addr = server.address()
const bind = typeof addr === 'string' ? `pipe ${addr}` : `port ${addr.port}`
const bind = typeof addr === 'string' ? `pipe ${addr}` : `port ${(addr as any).port}`
console.log(`Listening on ${bind}`)
}

Expand Down
17 changes: 12 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,24 @@
"name": "astrology_api",
"version": "1.3.0",
"description": "Api para el calculos astrologicos",
"main": "index.js",
"main": "dist/index.js",
"engines": {
"node": ">=14.x"
},
"scripts": {
"start": "node index.js",
"dev": "nodemon --watch src src/index.js",
"build": "tsc",
"start": "node dist/index.js",
"dev": "ts-node index.ts",
"test": "ENVIRONMENT=test jest",
"coverage": "ENVIRONMENT=test jest --coverage",
"coveralls": "ENVIRONMENT=test jest --coverage && cat ./coverage/lcov.info | coveralls",
"lint": "./node_modules/.bin/eslint --fix src"
},
"jest": {
"preset": "ts-jest",
"testEnvironment": "node",
"coveragePathIgnorePatterns": [
"./app.js"
"./app.ts"
]
},
"keywords": [
Expand All @@ -26,6 +29,7 @@
"devDependencies": {
"@types/express": "^4.17.6",
"@types/jest": "^25.2.1",
"@types/node": "^18.0.0",
"coveralls": "^3.0.9",
"eslint": "^8.15.0",
"eslint-config-standard": "^17.0.0",
Expand All @@ -34,7 +38,10 @@
"eslint-plugin-promise": "^6.0.0",
"jest": "^28.1.0",
"nodemon": "^2.0.4",
"supertest": "^4.0.2"
"supertest": "^4.0.2",
"ts-jest": "^28.0.0",
"ts-node": "^10.9.1",
"typescript": "^5.0.0"
},
"dependencies": {
"cors": "^2.8.5",
Expand Down
19 changes: 0 additions & 19 deletions src/api/index.js

This file was deleted.

19 changes: 19 additions & 0 deletions src/api/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import Router from 'express-promise-router'
import astrologer from '../astrologer'

const router = new Router()

router.get('/', async (_req, res) => res.status(200).json({ message: 'Welcome to Astrology api!' }))

router.get('/horoscope', async (req, res) => {
const date = new Date(req.query.time as string)
const { latitude, longitude, houseSystem } = req.query as Record<string, string>

const chart = astrologer.natalChart(date, latitude, longitude, houseSystem)

res.status(200).json({
data: chart
})
})

export default router
126 changes: 0 additions & 126 deletions src/astrologer/aspects.js

This file was deleted.

Loading
Loading