File size: 401 Bytes
181e22f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import moment from 'moment';

import {
  getRandomString,
  formatDatetimeForMySQL,
} from '../common/util';
import FileCode from '../models/FileCode';

export async function getCode(req, res, next) {
  const code = getRandomString(8);
  const expiredAt = formatDatetimeForMySQL(moment().add(1, 'days'));
  await FileCode.query().insert({
    code,
    expiredAt,
  });
  res.json({
    code,
  });
}