Cleanup socketio stuff for typescript

This commit is contained in:
Dane Everitt 2018-12-16 18:57:34 -08:00
parent 3ad4422a94
commit 5e4ca8ef83
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
22 changed files with 246 additions and 210 deletions

View file

@ -1,15 +1,18 @@
import axios, {AxiosResponse} from 'axios';
/**
* We'll load the axios HTTP library which allows us to easily issue requests
* to our Laravel back-end. This library automatically handles sending the
* CSRF token as a header based on the value of the "XSRF" token cookie.
*/
let axios = require('axios');
axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
axios.defaults.headers.common['Accept'] = 'application/json';
// Attach the response data to phpdebugbar so that we can see everything happening.
// @ts-ignore
if (typeof phpdebugbar !== 'undefined') {
axios.interceptors.response.use(function (response) {
axios.interceptors.response.use(function (response: AxiosResponse) {
// @ts-ignore
phpdebugbar.ajaxHandler.handle(response.request);
return response;

View file

@ -1,19 +1,16 @@
import format from 'date-fns/format';
import { format } from 'date-fns';
/**
* Return the human readable filesize for a given number of bytes. This
* uses 1024 as the base, so the response is denoted accordingly.
*
* @param {Number} bytes
* @return {String}
*/
export function readableSize (bytes) {
export function readableSize (bytes: number): string {
if (Math.abs(bytes) < 1024) {
return `${bytes} Bytes`;
}
let u = -1;
const units = ['KiB', 'MiB', 'GiB', 'TiB'];
let u: number = -1;
const units: Array<string> = ['KiB', 'MiB', 'GiB', 'TiB'];
do {
bytes /= 1024;
@ -25,10 +22,7 @@ export function readableSize (bytes) {
/**
* Format the given date as a human readable string.
*
* @param {String} date
* @return {String}
*/
export function formatDate (date) {
export function formatDate (date: string): string {
return format(date, 'MMM D, YYYY [at] HH:MM');
}