mirror of
https://github.com/uetchy/namae.git
synced 2025-10-14 15:12:18 +09:00
fix: rename components
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
const fetch = require('isomorphic-unfetch')
|
||||
const { send, sendError } = require('../util/http')
|
||||
const { send, sendError, fetch } = require('../util/http')
|
||||
|
||||
module.exports = async (req, res) => {
|
||||
const name = req.query.name
|
||||
|
@@ -14,7 +14,7 @@ module.exports = async (req, res) => {
|
||||
const name = req.query.name
|
||||
|
||||
if (!name) {
|
||||
return res.status(400).json({ error: 'no query given' })
|
||||
return sendError(res, new Error('no query given'))
|
||||
}
|
||||
|
||||
try {
|
||||
|
@@ -5,7 +5,7 @@ module.exports = async (req, res) => {
|
||||
const name = req.query.name
|
||||
|
||||
if (!name) {
|
||||
return res.status(400).json({ error: 'no query given' })
|
||||
return sendError(res, new Error('no query given'))
|
||||
}
|
||||
|
||||
try {
|
||||
|
@@ -1,20 +1,17 @@
|
||||
const fetch = require('isomorphic-unfetch')
|
||||
const { send, sendError } = require('../util/http')
|
||||
|
||||
async function getAvailability(name) {
|
||||
const response = await fetch(`https://github.com/${encodeURIComponent(name)}`)
|
||||
return response.status !== 200
|
||||
}
|
||||
const { send, sendError, fetch } = require('../util/http')
|
||||
|
||||
module.exports = async (req, res) => {
|
||||
const name = req.query.name
|
||||
|
||||
if (!name) {
|
||||
return res.status(400).json({ error: 'no query given' })
|
||||
return sendError(res, new Error('no query given'))
|
||||
}
|
||||
|
||||
try {
|
||||
const availability = await getAvailability(name)
|
||||
const response = await fetch(
|
||||
`https://github.com/${encodeURIComponent(name)}`
|
||||
)
|
||||
const availability = response.status !== 200
|
||||
send(res, availability)
|
||||
} catch (err) {
|
||||
sendError(res, err)
|
||||
|
@@ -5,7 +5,7 @@ module.exports = async (req, res) => {
|
||||
const name = req.query.name
|
||||
|
||||
if (!name) {
|
||||
return res.status(400).json({ error: 'no query given' })
|
||||
return sendError(res, new Error('no query given'))
|
||||
}
|
||||
|
||||
try {
|
||||
|
@@ -5,7 +5,7 @@ module.exports = async (req, res) => {
|
||||
const name = req.query.name
|
||||
|
||||
if (!name) {
|
||||
return res.status(400).json({ error: 'no query given' })
|
||||
return sendError(res, new Error('no query given'))
|
||||
}
|
||||
|
||||
try {
|
||||
|
@@ -1,22 +1,17 @@
|
||||
const fetch = require('isomorphic-unfetch')
|
||||
const { send, sendError } = require('../util/http')
|
||||
|
||||
async function getAvailability(name) {
|
||||
const response = await fetch(
|
||||
`https://pypi.org/pypi/${encodeURIComponent(name)}/json`
|
||||
)
|
||||
return response.status !== 200
|
||||
}
|
||||
const { send, sendError, fetch } = require('../util/http')
|
||||
|
||||
module.exports = async (req, res) => {
|
||||
const name = req.query.name
|
||||
|
||||
if (!name) {
|
||||
return res.status(400).json({ error: 'no query given' })
|
||||
return sendError(res, new Error('no query given'))
|
||||
}
|
||||
|
||||
try {
|
||||
const availability = await getAvailability(name)
|
||||
const response = await fetch(
|
||||
`https://pypi.org/pypi/${encodeURIComponent(name)}/json`
|
||||
)
|
||||
const availability = response.status !== 200
|
||||
send(res, availability)
|
||||
} catch (err) {
|
||||
sendError(res, err)
|
||||
|
@@ -1,11 +1,10 @@
|
||||
const fetch = require('isomorphic-unfetch')
|
||||
const { send, sendError } = require('../util/http')
|
||||
const { send, sendError, fetch } = require('../util/http')
|
||||
|
||||
module.exports = async (req, res) => {
|
||||
const name = req.query.name
|
||||
|
||||
if (!name) {
|
||||
return res.status(400).json({ error: 'no query given' })
|
||||
return sendError(res, new Error('no query given'))
|
||||
}
|
||||
|
||||
try {
|
||||
|
@@ -1,22 +1,17 @@
|
||||
const fetch = require('isomorphic-unfetch')
|
||||
const { send, sendError } = require('../util/http')
|
||||
|
||||
async function getAvailability(name) {
|
||||
const response = await fetch(
|
||||
`https://${encodeURIComponent(name)}.s3.amazonaws.com`
|
||||
)
|
||||
return response.status !== 200
|
||||
}
|
||||
const { send, sendError, fetch } = require('../util/http')
|
||||
|
||||
module.exports = async (req, res) => {
|
||||
const name = req.query.name
|
||||
|
||||
if (!name) {
|
||||
return res.status(400).json({ error: 'no query given' })
|
||||
return sendError(res, new Error('no query given'))
|
||||
}
|
||||
|
||||
try {
|
||||
const availability = await getAvailability(name)
|
||||
const response = await fetch(
|
||||
`https://${encodeURIComponent(name)}.s3.amazonaws.com`
|
||||
)
|
||||
const availability = response.status !== 200
|
||||
send(res, availability)
|
||||
} catch (err) {
|
||||
sendError(res, err)
|
||||
|
@@ -1,32 +1,23 @@
|
||||
const fetch = require('isomorphic-unfetch')
|
||||
const { send, sendError } = require('../util/http')
|
||||
|
||||
async function getAvailability(name) {
|
||||
try {
|
||||
const response = await fetch(
|
||||
`https://${encodeURIComponent(name)}.slack.com`
|
||||
)
|
||||
return response.status !== 200
|
||||
} catch (err) {
|
||||
if (err.code === 'ENOTFOUND') {
|
||||
return true
|
||||
} else {
|
||||
throw new Error(err.message)
|
||||
}
|
||||
}
|
||||
}
|
||||
const { send, sendError, fetch } = require('../util/http')
|
||||
|
||||
module.exports = async (req, res) => {
|
||||
const name = req.query.name
|
||||
|
||||
if (!name) {
|
||||
return res.status(400).json({ error: 'no query given' })
|
||||
return sendError(res, new Error('no query given'))
|
||||
}
|
||||
|
||||
try {
|
||||
const availability = await getAvailability(name)
|
||||
const response = await fetch(
|
||||
`https://${encodeURIComponent(name)}.slack.com`
|
||||
)
|
||||
const availability = response.status !== 200
|
||||
send(res, availability)
|
||||
} catch (err) {
|
||||
sendError(res, err)
|
||||
if (err.code === 'ENOTFOUND') {
|
||||
send(res, true)
|
||||
} else {
|
||||
sendError(res, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,12 +1,6 @@
|
||||
const fetch = require('isomorphic-unfetch')
|
||||
const { send, sendError } = require('../util/http')
|
||||
const { send, sendError, fetch } = require('../util/http')
|
||||
|
||||
async function getAvailability(name) {
|
||||
const response = await fetch(
|
||||
`https://twitter.com/${encodeURIComponent(name)}`
|
||||
)
|
||||
return response.status !== 200
|
||||
}
|
||||
async function getAvailability(name) {}
|
||||
|
||||
module.exports = async (req, res) => {
|
||||
const name = req.query.name
|
||||
@@ -16,7 +10,10 @@ module.exports = async (req, res) => {
|
||||
}
|
||||
|
||||
try {
|
||||
const availability = await getAvailability(name)
|
||||
const response = await fetch(
|
||||
`https://twitter.com/${encodeURIComponent(name)}`
|
||||
)
|
||||
const availability = response.status !== 200
|
||||
send(res, availability)
|
||||
} catch (err) {
|
||||
sendError(res, err)
|
||||
|
Reference in New Issue
Block a user