<prompt> Unda JavaScriptTypeScript Express.js RESTful API inayoauni shughuli za CRUD za kudhibiti mkusanyiko wa vitabu, ikijumuisha mada, waandishi na tarehe za kuchapishwa. Tumia PostgreSQL kama hifadhidata ya nyuma.PLINFORMAT  <response>: chapa srcindex.tskuagiza kama kueleza kutoka kueleza;kuagiza kama bodyParser kutoka body-parser;agiza bookRouter kutoka .routesbooks;const app express;app.usebodyParser.json;app.usevitabu, booksRouter;const port process.env.PORT 3000;app.listenbandari, console.logSeva inafanya kazi kwenye bandari port;; srcdb.tsimport as pgPromise kutoka pg-promise;kuagiza kama dotenv kutoka dotenv;dotenv.config;const pgp pgPromise;const db pgp mwenyeji: process.env.DB_HOST, bandari: Nambari process.env.DB_PORT, hifadhidata: process.env.DB_NAME, mtumiaji: process.env.DB_USER, nenosiri: process.env.DB_PASSWORD,;safirisha db chaguo-msingi; srcnjiavitabu.tsagiza Router, Ombi, Majibu kutoka kwa kueleza;kuagiza db kutoka ..db;export const booksRouter Router; Pata vitabu vyotebooksRouter.get, async req: Ombi, res: Response jaribu const books await db.anyCHAGUA KUTOKA vitabu; res.status200.jsonvitabu; kukamata kosa res.status500.jsonkosa ; ; Pata kitabu kwa kitambulishobooksRouter.get:id, async req: Ombi, res: Response const id parseIntreq.params.id; jaribu const book await db.oneOrNoneCHAGUA KUTOKA vitabu WAPI id 1, id; ikiwa kitabu hali.status200.jsonkitabu; nyengine res.status404.json ujumbe: Kitabu hakijapatikana ; kukamata kosa res.status500.jsonkosa ; ; Unda kitabu kipyabooksRouter.post, async req: Ombi, res: Response const title, mwandishi, publication_date req.body; jaribu const result subiri db.one WEKA NDANI ya vitabujina, mwandishi, tarehe_ya_kuchapishwa THAMANI1, 2, 3 ZINAZOREJESHA , kichwa, mwandishi, tarehe_ya kuchapishwa ; hali.hali201.jsonmatokeo; kukamata kosa res.status500.jsonkosa ; ; Sasisha kitabu kilichopobooksRouter.put:id, async req: Ombi, res: Response const id parseIntreq.params.id; const title, mwandishi, publication_date req.body; jaribu const result subiri matokeo ya db UPDATE vitabu SET title 1, mwandishi 2, publication_date 3 WHERE id 4, kichwa, mwandishi, tarehe_ya_kuchapishwa, kitambulisho ; ikiwa matokeo.rowCount 0 res.status200.json ujumbe: Kitabu kimesasishwa ; nyengine res.status404.json ujumbe: Kitabu hakijapatikana ; kukamata kosa res.status500.jsonkosa ; ; Futa kitabubooksRouter.delete:id, async req: Ombi, res: Response const id parseIntreq.params.id; jaribu const result await db.resultFUTA KUTOKA kwa vitabu WHERE id 1, id; ikiwa matokeo.rowCount 0 res.status200.json ujumbe: Kitabu kimefutwa ; nyengine res.status404.json ujumbe: Kitabu hakijapatikana ; kukamata kosa res.status500.jsonkosa ; ; 