@galadrim/galadmin 0.1.211 → 0.1.213
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/dist/api.js +30 -24
- package/dist/api.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/api.ts +29 -24
package/package.json
CHANGED
package/src/api.ts
CHANGED
|
@@ -923,30 +923,35 @@ export default (db, config, user) => {
|
|
|
923
923
|
if (!config.inseeKey) {
|
|
924
924
|
return res.status(403).send("inseeKey is not set in the config")
|
|
925
925
|
}
|
|
926
|
-
const
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
926
|
+
const processedQuery = (req.query.query as any).replaceAll(" ", "-")
|
|
927
|
+
try {
|
|
928
|
+
const response = await axios.get(`https://api.insee.fr/entreprises/sirene/siret`, {
|
|
929
|
+
headers: {
|
|
930
|
+
"Authorization": `Bearer ${config.inseeKey}`,
|
|
931
|
+
"Accept": "application/json"
|
|
932
|
+
},
|
|
933
|
+
params: {
|
|
934
|
+
q: `denominationUniteLegale:${processedQuery}* OR siren:${processedQuery}*`,
|
|
935
|
+
nombre: 100
|
|
936
|
+
}
|
|
937
|
+
});
|
|
938
|
+
const results = response.data.etablissements
|
|
939
|
+
.filter((etablissement) => etablissement.uniteLegale.etatAdministratifUniteLegale === "A")
|
|
940
|
+
.map((etablissement) => ({
|
|
941
|
+
id: Math.random().toString().slice(2),
|
|
942
|
+
companyName: etablissement.uniteLegale.denominationUniteLegale,
|
|
943
|
+
siret: etablissement.siret,
|
|
944
|
+
siren: etablissement.siren,
|
|
945
|
+
address: `${etablissement.adresseEtablissement.numeroVoieEtablissement || ""} ${etablissement.adresseEtablissement.typeVoieEtablissement || ""} ${etablissement.adresseEtablissement.libelleVoieEtablissement || ""}`,
|
|
946
|
+
city: etablissement.adresseEtablissement.libelleCommuneEtablissement,
|
|
947
|
+
zipCode: etablissement.adresseEtablissement.codePostalEtablissement,
|
|
948
|
+
activityNumber: etablissement.uniteLegale.activitePrincipaleUniteLegale,
|
|
949
|
+
}))
|
|
950
|
+
.slice(0, 10)
|
|
951
|
+
res.send(results)
|
|
952
|
+
} catch (e) {
|
|
953
|
+
res.send([])
|
|
954
|
+
}
|
|
950
955
|
})
|
|
951
956
|
|
|
952
957
|
return app
|