<commit_before>import express from 'express';
import {Article} from '../db/index';

/**
 * @swagger
 * definition:
 *   Article:
 *     properties:
 *       id:
 *         type: integer
 *       title:
 *         type: string
 *       description:
 *         type: string
 *       content:
 *         type: string
 *       createdAt:
 *         type: string
 *       updatedAt:
 *         type: string
 */

export function articleService(app: express.Application) {

    /**
     * @swagger
     * /api/article/{id}:
     *   get:
     *     tags:
     *       - Article
     *     description: Returns a single article.
     *     produces:
     *       - application/json
     *     parameters:
     *       - name: id
     *         description: Id of the article.
     *         in: path
     *         required: true
     *         type: integer
     *     responses:
     *       200:
     *         description: A single article.
     *         schema:
     *           $ref: '#/definitions/Article'
     */
    app.get('/api/article/:id', async (req, res) => {
        res.json(await Article.findById(req.params.id));
    });

    /**
     * @swagger
     * /api/article:
     *   get:
     *     tags:
     *       - Article
     *     description: Returns all the articles.
     *     produces:
     *       - application/json
     *     parameters:
     *       - name: none
     *         description: none.
     *         in: path
     *         required: true
     *         type: any
     *     responses:
     *       200:
     *         description: Returns all the articles.
     *         schema:<commit_msg>Updating find all article description<commit_after>import express from 'express';
import {Article} from '../db/index';

/**
 * @swagger
 * definition:
 *   Article:
 *     properties:
 *       id:
 *         type: integer
 *       title:
 *         type: string
 *       description:
 *         type: string
 *       content:
 *         type: string
 *       createdAt:
 *         type: string
 *       updatedAt:
 *         type: string
 */

export function articleService(app: express.Application) {

    /**
     * @swagger
     * /api/article/{id}:
     *   get:
     *     tags:
     *       - Article
     *     description: Returns a single article.
     *     produces:
     *       - application/json
     *     parameters:
     *       - name: id
     *         description: Id of the article.
     *         in: path
     *         required: true
     *         type: integer
     *     responses:
     *       200:
     *         description: A single article.
     *         schema:
     *           $ref: '#/definitions/Article'
     */
    app.get('/api/article/:id', async (req, res) => {
        res.json(await Article.findById(req.params.id));
    });

    /**
     * @swagger
     * /api/article:
     *   get:
     *     tags:
     *       - Article
     *     description: Returns all the articles.
     *     produces:
     *       - application/json
     *     parameters:
     *       - name: search
     *         description: maximum number of results to return.
     *         in: path
     *         required: false
     *         type: any
     *     responses:
     *       200:
     *         description: Returns all the articles.
     *         schema:
{'fraction_non_alphanumeric': 0.11413043478260869, 'fraction_numerical': 0.0036231884057971015, 'mean_word_length': 1.2385135135135135, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '894885', 'n_tokens_mistral': 941, 'n_tokens_neox': 936, 'n_words': 220}